Sha256: c7fe563e9a8dac271c1dabb3c56addd07dacf6dec4e7f0b402c4c15926d09583
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module GraphQL module Autoload # 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!} # @param const_name [Symbol] # @param path [String] # @return [void] def autoload(const_name, path) @_eagerloaded_constants ||= [] @_eagerloaded_constants << const_name super const_name, path end # Call this to load this constant's `autoload` dependents and continue calling recursively # @return [void] 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 private # @return [Boolean] `true` if GraphQL-Ruby is currently eager-loading its constants def eager_loading? @_eager_loading ||= false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-2.4.6 | lib/graphql/autoload.rb |
graphql-2.4.5 | lib/graphql/autoload.rb |