Class: GQL::Lazy

Inherits:
Field show all
Defined in:
lib/gql/lazy.rb

Instance Attribute Summary

Attributes inherited from Field

#ast_node, #context, #target, #variables

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Field

execute, #initialize, #scalar_value

Methods included from Mixins::Common

#propagate, #shutdown

Constructor Details

This class inherits a constructor from GQL::Field

Class Method Details

.build_class(id, proc, options) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/gql/lazy.rb', line 8

def build_class(id, proc, options)
  Class.new(self).tap do |field_class|
    field_class.owner   = options.delete(:owner)
    field_class.type    = options.delete(:type)
    field_class.id      = id
    field_class.proc    = proc
    field_class.options = options
  end
end

.spurObject



18
19
20
21
22
# File 'lib/gql/lazy.rb', line 18

def spur
  return spur_unknown_field_type if type.is_a? ::Symbol

  owner.add_field id, proc, options.merge(type: Registry.fetch(type))
end

Instance Method Details

#valueObject



32
33
34
35
36
37
# File 'lib/gql/lazy.rb', line 32

def value
  field_class = self.class.spur

  field = field_class.new(ast_node, target, variables, context)
  field.value
end