Module: Doorkeeper::Orm::ActiveRecord

Defined in:
lib/doorkeeper/orm/active_record.rb,
lib/doorkeeper/orm/active_record/stale_records_cleaner.rb

Overview

ActiveRecord ORM for Doorkeeper entity models. Consists of three main OAuth entities:

* Access Token
* Access Grant
* Application (client)

Do a lazy loading of all the required and configured stuff.

Defined Under Namespace

Modules: Mixins Classes: StaleRecordsCleaner

Class Method Summary collapse

Class Method Details

.initialize_application_owner!Object


31
32
33
34
35
36
37
# File 'lib/doorkeeper/orm/active_record.rb', line 31

def self.initialize_application_owner!
  lazy_load do
    require "doorkeeper/models/concerns/ownership"

    Doorkeeper.config.application_model.include(Doorkeeper::Models::Ownership)
  end
end

.initialize_models!Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/doorkeeper/orm/active_record.rb', line 16

def self.initialize_models!
  lazy_load do
    require "doorkeeper/orm/active_record/stale_records_cleaner"
    require "doorkeeper/orm/active_record/access_grant"
    require "doorkeeper/orm/active_record/access_token"
    require "doorkeeper/orm/active_record/application"

    if (options = Doorkeeper.config.active_record_options[:establish_connection])
      Doorkeeper::Orm::ActiveRecord.models.each do |model|
        model.establish_connection(options)
      end
    end
  end
end

.lazy_load(&block) ⇒ Object


39
40
41
# File 'lib/doorkeeper/orm/active_record.rb', line 39

def self.lazy_load(&block)
  ActiveSupport.on_load(:active_record, {}, &block)
end

.modelsObject


43
44
45
46
47
48
49
# File 'lib/doorkeeper/orm/active_record.rb', line 43

def self.models
  [
    Doorkeeper.config.access_grant_model,
    Doorkeeper.config.access_token_model,
    Doorkeeper.config.application_model,
  ]
end