Module: GraphQL::Autoload
Overview
See GraphQL::Railtie for automatic Rails integration
@requires_ancestor: Module
Instance Method Summary collapse
-
#autoload(const_name, path) ⇒ Object
Register a constant named
const_nameto be loaded frompath. -
#eager_load! ⇒ Object
Call this to load this constant's
autoloaddependents and continue calling recursively.
Instance Method Details
#autoload(const_name, path) ⇒ Object
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!
Parameters
const_name(Symbol)path(String)
Returns
void
:call-seq:
autoload(Symbol const_name, String path) -> void
24 25 26 27 28 29 |
# File 'lib/graphql/autoload.rb', line 24 def autoload(const_name, path) @_eagerloaded_constants ||= [] @_eagerloaded_constants << const_name super const_name, path end |
#eager_load! ⇒ Object
Call this to load this constant's autoload dependents and continue calling recursively
Returns
void
:call-seq:
eager_load!() -> void
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/graphql/autoload.rb', line 39 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 |