Class: GQL::Object

Inherits:
Field
  • Object
show all
Defined in:
lib/gql/object.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
17
# File 'lib/gql/object.rb', line 8

def build_class(id, proc, options = {})
  object_class = options.delete(:object_class) || options.delete(:as)
  object_proc  = object_proc_for_class(object_class)

  Class.new(self).tap do |klass|
    klass.id = id
    klass.proc = proc
    klass.object_proc = object_proc
  end
end

Instance Method Details

#valueObject



34
35
36
37
38
39
# File 'lib/gql/object.rb', line 34

def value
  field_class = Registry.fetch(object_proc_result)

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