Class: Rjq::AST::ObjectLiteral
Defined Under Namespace
Classes: Pair
Instance Attribute Summary collapse
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
Attributes inherited from Node
Instance Method Summary collapse
- #eval(input, context) ⇒ Object
-
#initialize(pairs) ⇒ ObjectLiteral
constructor
A new instance of ObjectLiteral.
Methods inherited from Node
#assign_value, #invalid_path_message, #paths, #take, #with_source_span
Constructor Details
#initialize(pairs) ⇒ ObjectLiteral
Returns a new instance of ObjectLiteral.
643 644 645 |
# File 'lib/rjq/ast.rb', line 643 def initialize(pairs) @pairs = pairs end |
Instance Attribute Details
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs.
641 642 643 |
# File 'lib/rjq/ast.rb', line 641 def pairs @pairs end |
Instance Method Details
#eval(input, context) ⇒ Object
647 648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/rjq/ast.rb', line 647 def eval(input, context) objects = [{}] @pairs.each do |pair| key_values = key_outputs(pair.key, input, context) value_values = pair.value.eval(input, context) objects = objects.flat_map do |object| key_values.flat_map do |key| value_values.map { |value| object.merge(key.to_s => value) } end end end objects end |