Class: DynamoidAdvancedWhere::Nodes::OrNode
- Includes:
- Concerns::Negatable
- Defined in:
- lib/dynamoid_advanced_where/nodes/or_node.rb
Instance Attribute Summary collapse
-
#child_nodes ⇒ Object
Returns the value of attribute child_nodes.
Attributes inherited from BaseNode
Instance Method Summary collapse
- #expression_attribute_names ⇒ Object
- #expression_attribute_values ⇒ Object
-
#initialize(*child_nodes) ⇒ OrNode
constructor
A new instance of OrNode.
- #or(other_value) ⇒ Object (also: #|)
- #to_expression ⇒ Object
Methods included from Concerns::Negatable
Constructor Details
#initialize(*child_nodes) ⇒ OrNode
Returns a new instance of OrNode.
9 10 11 12 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 9 def initialize(*child_nodes) self.child_nodes = child_nodes.freeze freeze end |
Instance Attribute Details
#child_nodes ⇒ Object
Returns the value of attribute child_nodes.
7 8 9 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 7 def child_nodes @child_nodes end |
Instance Method Details
#expression_attribute_names ⇒ Object
20 21 22 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 20 def expression_attribute_names child_nodes.map(&:expression_attribute_names).inject({}, &:merge!) end |
#expression_attribute_values ⇒ Object
24 25 26 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 24 def expression_attribute_values child_nodes.map(&:expression_attribute_values).inject({}, &:merge!) end |
#or(other_value) ⇒ Object Also known as: |
28 29 30 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 28 def or(other_value) OrNode.new(other_value, *child_nodes) end |
#to_expression ⇒ Object
14 15 16 17 18 |
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 14 def to_expression return if child_nodes.empty? "(#{child_nodes.map(&:to_expression).join(') or (')})" end |