Module: GraphQL::Autoload
Overview
Instance Method Summary collapse
-
#autoload(const_name, path) ⇒ void
Register a constant named
const_name
to be loaded frompath
. -
#eager_load! ⇒ void
Call this to load this constant's
autoload
dependents and continue calling recursively.
Instance Method Details
#autoload(const_name, path) ⇒ void
This method returns an undefined value.
Register a constant named const_name
to be loaded from path
.
This is like Kernel#autoload
but it tracks the constants so they can be eager-loaded with #eager_load!
11 12 13 14 15 16 |
# File 'lib/graphql/autoload.rb', line 11 def autoload(const_name, path) @_eagerloaded_constants ||= [] @_eagerloaded_constants << const_name super const_name, path end |
#eager_load! ⇒ void
This method returns an undefined value.
Call this to load this constant's autoload
dependents and continue calling recursively
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/graphql/autoload.rb', line 20 def eager_load! @_eager_loading = true if @_eagerloaded_constants @_eagerloaded_constants.each { |const_name| const_get(const_name) } @_eagerloaded_constants = nil end nil ensure @_eager_loading = false end |