class GraphQL::Execution::Lazy::LazyMethodMap

@see {Schema#lazy?} looks up values from this map
@api private
Instances of this class are thread-safe.
The result of this lookup is cached for future resolutions.
Methods may be registered for classes, they apply to its subclasses also.
{GraphQL::Schema} uses this to match returned values to lazy resolution methods.

def find_superclass_method(value_class)

def find_superclass_method(value_class)
  @storage.each_pair { |lazy_class, lazy_value_method|
    return lazy_value_method if value_class < lazy_class
  }
  nil
end

def get(value)

Returns:
  • (Symbol, nil) - The `lazy_value_method` for this object, or nil

Parameters:
  • value (Object) -- an object which may have a `lazy_value_method` registered for its class or superclasses
def get(value)
  @storage.compute_if_absent(value.class) { find_superclass_method(value.class) }
end

def initialize(use_concurrent: defined?(Concurrent::Map))

def initialize(use_concurrent: defined?(Concurrent::Map))
  @storage = use_concurrent ? Concurrent::Map.new : ConcurrentishMap.new
end

def initialize_copy(other)

def initialize_copy(other)
  @storage = other.storage.dup
end

def set(lazy_class, lazy_value_method)

Parameters:
  • lazy_value_method (Symbol) -- The method to call on this class to get its value
  • lazy_class (Class) -- A class which represents a lazy value (subclasses may also be used)
def set(lazy_class, lazy_value_method)
  @storage[lazy_class] = lazy_value_method
end