Skip to content

Commit c41b321

Browse files
authored
Merge pull request #102 from y-yagi/eager_load_constants
Eager load the constants
2 parents b7c5f6d + 797a383 commit c41b321

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/global_id.rb

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
require 'global_id/global_id'
2+
require 'active_support'
23

34
autoload :SignedGlobalID, 'global_id/signed_global_id'
45

56
class GlobalID
6-
autoload :Locator, 'global_id/locator'
7-
autoload :Identification, 'global_id/identification'
8-
autoload :Verifier, 'global_id/verifier'
7+
extend ActiveSupport::Autoload
8+
9+
eager_autoload do
10+
autoload :Locator
11+
autoload :Identification
12+
autoload :Verifier
13+
end
14+
15+
def self.eager_load!
16+
super
17+
require 'global_id/signed_global_id'
18+
end
919
end

lib/global_id/railtie.rb

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class GlobalID
1111
# Set up the signed GlobalID verifier and include Active Record support.
1212
class Railtie < Rails::Railtie # :nodoc:
1313
config.global_id = ActiveSupport::OrderedOptions.new
14+
config.eager_load_namespaces << GlobalID
1415

1516
initializer 'global_id' do |app|
1617

0 commit comments

Comments
 (0)