Class: GQL::Object

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

Instance Attribute Summary

Attributes inherited from Node

#ast_node, #context, #target, #variables

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

call, cursor, field, #initialize, method_missing, #raw_value, respond_to?, validate_is_subclass!, #value_of_call, #value_of_field, #value_of_fields

Constructor Details

This class inherits a constructor from GQL::Node

Class Method Details

.build_class(id, proc, options = {}) ⇒ Object



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

def build_class(id, proc, options = {})
  node_class = options[:node_class] || self.node_class

  Node.validate_is_subclass! node_class, 'node'

  Class.new(self).tap do |field_class|
    field_class.id = id.to_s
    field_class.proc = proc
    field_class.node_class = node_class
  end
end

Instance Method Details

#valueObject



21
22
23
24
# File 'lib/gql/object.rb', line 21

def value
  node = self.class.node_class.new(ast_node, target, variables, context)
  node.value
end