Class: GQL::Executor

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast_query) ⇒ Executor

Returns a new instance of Executor.



5
6
7
8
# File 'lib/gql/executor.rb', line 5

def initialize(ast_query)
  @ast_root   = ast_query.root
  @variables  = ast_query.variables
end

Instance Attribute Details

#ast_rootObject (readonly)

Returns the value of attribute ast_root.



3
4
5
# File 'lib/gql/executor.rb', line 3

def ast_root
  @ast_root
end

#variablesObject (readonly)

Returns the value of attribute variables.



3
4
5
# File 'lib/gql/executor.rb', line 3

def variables
  @variables
end

Instance Method Details

#execute(context = {}, vars = {}) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/gql/executor.rb', line 10

def execute(context = {}, vars = {})
  raise Errors::RootClassNotSet unless GQL.root_class

  root_class = Registry.fetch(GQL.root_class)
  root_class.id = ast_root.id
  root_class.proc = GQL.root_target_proc
  root_class.execute self.class, ast_root, nil, variables.merge(vars), context
end