Class: GQL::Fields::Connection

Inherits:
GQL::Field show all
Defined in:
lib/gql/fields/connection.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, #value, #value_of_call, #value_of_field

Constructor Details

This class inherits a constructor from GQL::Node

Class Method Details

.build_class(method, options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gql/fields/connection.rb', line 10

def build_class(method, options = {})
  connection_class = options[:connection_class] || self.connection_class

  if connection_class.nil?
    raise Errors::UndefinedNodeClass.new(self, 'connection')
  end

  unless connection_class <= GQL::Connection
    raise Errors::InvalidNodeClass.new(connection_class, GQL::Connection)
  end

  Class.new(self).tap do |field_class|
    field_class.method = method
    field_class.connection_class = connection_class.build_class(options[:node_class])
  end
end

Instance Method Details

#raw_valueObject



33
34
35
# File 'lib/gql/fields/connection.rb', line 33

def raw_value
  nil
end

#value_of_fieldsObject



28
29
30
31
# File 'lib/gql/fields/connection.rb', line 28

def value_of_fields(*)
  connection = self.class.connection_class.new(ast_node, target, variables, context)
  connection.value
end