Class: GQL::Field
- Inherits:
-
Object
- Object
- GQL::Field
- Extended by:
- Mixins::Common
- Includes:
- Mixins::HasCalls, Mixins::HasFields
- Defined in:
- lib/gql/field.rb
Direct Known Subclasses
Array, Connection, Lazy, Object, Scalar, Schema::Call, Schema::CallerClass, Schema::Field, Schema::List, Schema::Parameter
Instance Attribute Summary collapse
-
#ast_node ⇒ Object
readonly
Returns the value of attribute ast_node.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ast_node, target, variables, context) ⇒ Field
constructor
A new instance of Field.
- #scalar_value ⇒ Object
- #value ⇒ Object
Methods included from Mixins::Common
Constructor Details
#initialize(ast_node, target, variables, context) ⇒ Field
Returns a new instance of Field.
26 27 28 29 |
# File 'lib/gql/field.rb', line 26 def initialize(ast_node, target, variables, context) @ast_node, @target = ast_node, target @variables, @context = variables, context end |
Instance Attribute Details
#ast_node ⇒ Object (readonly)
Returns the value of attribute ast_node.
24 25 26 |
# File 'lib/gql/field.rb', line 24 def ast_node @ast_node end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
24 25 26 |
# File 'lib/gql/field.rb', line 24 def context @context end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
24 25 26 |
# File 'lib/gql/field.rb', line 24 def target @target end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
24 25 26 |
# File 'lib/gql/field.rb', line 24 def variables @variables end |
Class Method Details
.build_class(id, proc, options = {}) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/gql/field.rb', line 12 def build_class(id, proc, = {}) Class.new(self).tap do |field_class| field_class.id = id.to_s field_class.proc = proc end end |
Instance Method Details
#scalar_value ⇒ Object
41 42 43 |
# File 'lib/gql/field.rb', line 41 def scalar_value nil end |
#value ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/gql/field.rb', line 31 def value if ast_call = ast_node.call value_of_call ast_call elsif ast_fields = ast_node.fields value_of_fields ast_fields else scalar_value end end |