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.
Class Method Summary collapse
- .execute(caller_class, ast_node, target, variables, context) ⇒ Object
- .parameters ⇒ Object
- .returns(result_class = nil, &block) ⇒ Object
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(target, context) ⇒ Call
constructor
A new instance of Call.
Constructor Details
#initialize(target, context) ⇒ Call
Returns a new instance of Call.
48 49 50 |
# File 'lib/gql/call.rb', line 48 def initialize(target, context) @target, @context = target, context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
46 47 48 |
# File 'lib/gql/call.rb', line 46 def context @context end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
46 47 48 |
# File 'lib/gql/call.rb', line 46 def target @target end |
Class Method Details
.execute(caller_class, ast_node, target, variables, context) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/gql/call.rb', line 12 def execute(caller_class, ast_node, target, variables, context) args = substitute_variables(ast_node.arguments, variables.dup) target = new(target, context).execute(*args) next_class = result_class || caller_class result = next_class.new(ast_node, target, variables, context) result.value end |
.parameters ⇒ Object
22 23 24 |
# File 'lib/gql/call.rb', line 22 def parameters (proc || instance_method(:execute)).parameters end |
.returns(result_class = nil, &block) ⇒ Object
8 9 10 |
# File 'lib/gql/call.rb', line 8 def returns(result_class = nil, &block) self.result_class = result_class || result_class_from_block(block) end |
Instance Method Details
#execute ⇒ Object
52 53 54 |
# File 'lib/gql/call.rb', line 52 def execute(*) raise NotImplementedError, 'override in subclass' end |