Sha256: 111efc3002745e1b5c00a46eb9a5a6e3124d4899108e8333f6717d3894122c6d

Contents?: true

Size: 1.04 KB

Versions: 6

Compression:

Stored size: 1.04 KB

Contents

require 'active_support/lazy_load_hooks'

module Doorkeeper
  module Orm
    module ActiveRecord
      def self.initialize_models!
        lazy_load do
          require 'doorkeeper/orm/active_record/access_grant'
          require 'doorkeeper/orm/active_record/access_token'
          require 'doorkeeper/orm/active_record/application'

          if Doorkeeper.configuration.active_record_options[:establish_connection]
            [Doorkeeper::AccessGrant, Doorkeeper::AccessToken, Doorkeeper::Application].each do |model|
              options = Doorkeeper.configuration.active_record_options[:establish_connection]
              model.establish_connection(options)
            end
          end
        end
      end

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

          Doorkeeper::Application.send :include, Doorkeeper::Models::Ownership
        end
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
doorkeeper-4.4.3 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.4.2 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.4.1 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.4.0 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.3.2 lib/doorkeeper/orm/active_record.rb
doorkeeper-4.3.1 lib/doorkeeper/orm/active_record.rb