Class: GQL::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/gql/call.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#contextObject (readonly)

Returns the value of attribute context.



46
47
48
# File 'lib/gql/call.rb', line 46

def context
  @context
end

#targetObject (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

.parametersObject



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

#executeObject

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/gql/call.rb', line 52

def execute(*)
  raise NotImplementedError, 'override in subclass'
end