Class: DynamoidAdvancedWhere::Nodes::OrNode

Inherits:
BaseNode
  • Object
show all
Includes:
Concerns::Negatable
Defined in:
lib/dynamoid_advanced_where/nodes/or_node.rb

Instance Attribute Summary collapse

Attributes inherited from BaseNode

#expression_prefix

Instance Method Summary collapse

Methods included from Concerns::Negatable

#negate

Constructor Details

#initialize(*child_nodes) ⇒ OrNode

Returns a new instance of OrNode.



7
8
9
10
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 7

def initialize(*child_nodes)
  self.child_nodes = child_nodes.freeze
  freeze
end

Instance Attribute Details

#child_nodesObject

Returns the value of attribute child_nodes.



5
6
7
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 5

def child_nodes
  @child_nodes
end

Instance Method Details

#expression_attribute_namesObject



18
19
20
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 18

def expression_attribute_names
  child_nodes.map(&:expression_attribute_names).inject({}, &:merge!)
end

#expression_attribute_valuesObject



22
23
24
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 22

def expression_attribute_values
  child_nodes.map(&:expression_attribute_values).inject({}, &:merge!)
end

#or(other_value) ⇒ Object Also known as: |



26
27
28
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 26

def or(other_value)
  OrNode.new(other_value, *child_nodes)
end

#to_expressionObject



12
13
14
15
16
# File 'lib/dynamoid_advanced_where/nodes/or_node.rb', line 12

def to_expression
  return if child_nodes.empty?

  "(#{child_nodes.map(&:to_expression).join(') or (')})"
end