Skip to content

Commit

Permalink
Load ORM after initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Apr 2, 2021
1 parent bf32b4d commit ede5879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/doorkeeper/config.rb
Expand Up @@ -23,9 +23,6 @@ class MissingConfigurationBuilderClass < StandardError; end
class << self
def configure(&block)
@config = Config::Builder.new(&block).build
setup_orm_adapter
setup_orm_models
setup_application_owner if @config.enable_application_owner?
@config
end

Expand All @@ -37,6 +34,12 @@ def configuration

alias config configuration

def setup_orm
setup_orm_adapter
setup_orm_models
setup_application_owner if @config && @config.enable_application_owner?
end

def setup_orm_adapter
@orm_adapter = "doorkeeper/orm/#{configuration.orm}".classify.constantize
rescue NameError => e
Expand Down
4 changes: 4 additions & 0 deletions lib/doorkeeper/engine.rb
Expand Up @@ -17,6 +17,10 @@ class Engine < Rails::Engine
end
end

config.after_initialize do
Doorkeeper.setup_orm
end

if defined?(Sprockets) && Sprockets::VERSION.chr.to_i >= 4
initializer "doorkeeper.assets.precompile" do |app|
# Force users to use:
Expand Down

0 comments on commit ede5879

Please sign in to comment.