Class: GQL::Call
- Inherits:
-
Object
- Object
- GQL::Call
- Defined in:
- lib/gql/call.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(caller, ast_node, target, definition, variables, context) ⇒ Call
constructor
A new instance of Call.
Constructor Details
#initialize(caller, ast_node, target, definition, variables, context) ⇒ Call
5 6 7 8 |
# File 'lib/gql/call.rb', line 5 def initialize(caller, ast_node, target, definition, variables, context) @caller, @ast_node, @target = caller, ast_node, target @definition, @variables, @context = definition, variables, context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/gql/call.rb', line 3 def context @context end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'lib/gql/call.rb', line 3 def target @target end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gql/call.rb', line 10 def execute args = @ast_node.arguments.map { |arg| arg.is_a?(Symbol) ? @variables[arg] : arg } target = instance_exec(*args, &@definition[:body]) node_class = @definition[:returns] || @caller.class raise Errors::InvalidNodeClass.new(node_class, Node) unless node_class < Node node = node_class.new(@ast_node, target, @variables, context) node.__value end |