Class: GraphQL::Execution::Lazy::LazyMethodMap
- Inherits:
-
Object
- Object
- GraphQL::Execution::Lazy::LazyMethodMap
- Defined in:
- lib/graphql/execution/lazy/lazy_method_map.rb
Overview
Schema uses this to match returned values to lazy resolution methods. Methods may be registered for classes, they apply to its subclasses also. The result of this lookup is cached for future resolutions.
Instance Method Summary collapse
- #each ⇒ Object
-
#get(value) ⇒ Symbol?
The
lazy_value_method
for this object, or nil. -
#initialize ⇒ LazyMethodMap
constructor
A new instance of LazyMethodMap.
- #set(lazy_class, lazy_value_method) ⇒ Object
Constructor Details
#initialize ⇒ LazyMethodMap
Returns a new instance of LazyMethodMap.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 9 def initialize @storage = Hash.new do |h, value_class| registered_superclass = h.each_key.find { |lazy_class| value_class < lazy_class } if registered_superclass.nil? h[value_class] = nil else h[value_class] = h[registered_superclass] end end end |
Instance Method Details
#each ⇒ Object
32 33 34 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 32 def each @storage.each { |k, v| yield(k,v) } end |
#get(value) ⇒ Symbol?
Returns The lazy_value_method
for this object, or nil.
28 29 30 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 28 def get(value) @storage[value.class] end |
#set(lazy_class, lazy_value_method) ⇒ Object
22 23 24 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 22 def set(lazy_class, lazy_value_method) @storage[lazy_class] = lazy_value_method end |