Sha256: 5db03b8ea29dd9996c95f62bb2b3b0de21925d8382bb280a3b45790418d73f96

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require 'active_support/lazy_load_hooks'

module Doorkeeper
  module Orm
    module MongoMapper
      def self.initialize_models!
        install_dependencies!

        lazy_load do
          require 'doorkeeper/orm/mongo_mapper/access_grant'
          require 'doorkeeper/orm/mongo_mapper/access_token'
          require 'doorkeeper/orm/mongo_mapper/application'
          require 'doorkeeper/orm/mongo_mapper/stale_records_cleaner'
        end
      end

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

          Doorkeeper::Application.send :include, Doorkeeper::Orm::Concerns::MongoMapper::Ownership
        end
      end

      def self.check_requirements!(_config); end

      def self.install_dependencies!
        if ::ActiveModel::VERSION::MAJOR >= 5
          begin
            require 'activemodel-serializers-xml'
          rescue LoadError
            $stderr.print 'Failed to load ActiveModel::Serializers::Xml. ' \
                          "You need to add 'activemodel-serializers-xml' gem to your Gemfile."
            raise
          end
        end
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper-mongodb-5.0.0 lib/doorkeeper/orm/mongo_mapper.rb