Class: GraphQL::Execution::Lazy::LazyMethodMap Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::Lazy::LazyMethodMap
- Defined in:
- lib/graphql/execution/lazy/lazy_method_map.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
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. Instances of this class are thread-safe.
Defined Under Namespace
Classes: ConcurrentishMap
Instance Method Summary collapse
- #each ⇒ Object private
-
#get(value) ⇒ Symbol?
private
The
lazy_value_method
for this object, or nil. -
#initialize(use_concurrent: defined?(Concurrent::Map)) ⇒ LazyMethodMap
constructor
private
A new instance of LazyMethodMap.
- #initialize_copy(other) ⇒ Object private
- #set(lazy_class, lazy_value_method) ⇒ Object private
Constructor Details
#initialize(use_concurrent: defined?(Concurrent::Map)) ⇒ LazyMethodMap
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of LazyMethodMap.
19 20 21 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 19 def initialize(use_concurrent: defined?(Concurrent::Map)) @storage = use_concurrent ? Concurrent::Map.new : ConcurrentishMap.new end |
Instance Method Details
#each ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 39 def each @storage.each_pair { |k, v| yield(k, v) } end |
#get(value) ⇒ Symbol?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns The lazy_value_method
for this object, or nil.
35 36 37 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 35 def get(value) @storage.compute_if_absent(value.class) { find_superclass_method(value.class) } end |
#initialize_copy(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 23 def initialize_copy(other) @storage = other.storage.dup end |
#set(lazy_class, lazy_value_method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
29 30 31 |
# File 'lib/graphql/execution/lazy/lazy_method_map.rb', line 29 def set(lazy_class, lazy_value_method) @storage[lazy_class] = lazy_value_method end |