Class: GQL::Executor
- Inherits:
-
Object
- Object
- GQL::Executor
- Defined in:
- lib/gql/executor.rb
Instance Attribute Summary collapse
-
#ast_root ⇒ Object
readonly
Returns the value of attribute ast_root.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #execute(context = {}, vars = {}) ⇒ Object
-
#initialize(ast_query) ⇒ Executor
constructor
A new instance of Executor.
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_root ⇒ Object (readonly)
Returns the value of attribute ast_root.
3 4 5 |
# File 'lib/gql/executor.rb', line 3 def ast_root @ast_root end |
#variables ⇒ Object (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 |