Skip to content

Commit

Permalink
Merge pull request #102 from y-yagi/eager_load_constants
Browse files Browse the repository at this point in the history
Eager load the constants
  • Loading branch information
rafaelfranca committed Aug 16, 2017
2 parents b7c5f6d + 797a383 commit c41b321
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/global_id.rb
@@ -1,9 +1,19 @@
require 'global_id/global_id'
require 'active_support'

autoload :SignedGlobalID, 'global_id/signed_global_id'

class GlobalID
autoload :Locator, 'global_id/locator'
autoload :Identification, 'global_id/identification'
autoload :Verifier, 'global_id/verifier'
extend ActiveSupport::Autoload

eager_autoload do
autoload :Locator
autoload :Identification
autoload :Verifier
end

def self.eager_load!
super
require 'global_id/signed_global_id'
end
end
1 change: 1 addition & 0 deletions lib/global_id/railtie.rb
Expand Up @@ -11,6 +11,7 @@ class GlobalID
# Set up the signed GlobalID verifier and include Active Record support.
class Railtie < Rails::Railtie # :nodoc:
config.global_id = ActiveSupport::OrderedOptions.new
config.eager_load_namespaces << GlobalID

initializer 'global_id' do |app|

Expand Down

0 comments on commit c41b321

Please sign in to comment.