module Doorkeeper

def self.configuration

def self.configuration
  @config
end

def self.configure(&block)

def self.configure(&block)
  @config = Config::Builder.new(&block).build
  enable_orm
  setup_application_owner if @config.enable_application_owner?
end

def self.configured?

def self.configured?
  @config.present?
end

def self.database_installed?

def self.database_installed?
  [AccessToken, AccessGrant, Application].all? { |model| model.table_exists? }
end

def self.enable_orm

def self.enable_orm
  require "doorkeeper/models/#{@config.orm}/access_grant"
  require "doorkeeper/models/#{@config.orm}/access_token"
  require "doorkeeper/models/#{@config.orm}/application"
  require 'doorkeeper/models/access_grant'
  require 'doorkeeper/models/access_token'
  require 'doorkeeper/models/application'
end

def self.installed?

def self.installed?
  configured? && database_installed?
end

def self.setup_application_owner

def self.setup_application_owner
  require File.join(File.dirname(__FILE__), 'models', 'ownership')
  Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
end