Class: DynamoidAdvancedWhere::Nodes::AndNode

Inherits:
BaseNode
  • Object
show all
Includes:
Concerns::Negatable
Defined in:
lib/dynamoid_advanced_where/nodes/and_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) ⇒ AndNode

Returns a new instance of AndNode.



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

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

Instance Attribute Details

#child_nodesObject

Returns the value of attribute child_nodes.



20
21
22
# File 'lib/dynamoid_advanced_where/nodes/and_node.rb', line 20

def child_nodes
  @child_nodes
end

Instance Method Details

#and(other_value) ⇒ Object Also known as: &



41
42
43
# File 'lib/dynamoid_advanced_where/nodes/and_node.rb', line 41

def and(other_value)
  AndNode.new(other_value, *child_nodes)
end

#expression_attribute_namesObject



33
34
35
# File 'lib/dynamoid_advanced_where/nodes/and_node.rb', line 33

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

#expression_attribute_valuesObject



37
38
39
# File 'lib/dynamoid_advanced_where/nodes/and_node.rb', line 37

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

#to_expressionObject



27
28
29
30
31
# File 'lib/dynamoid_advanced_where/nodes/and_node.rb', line 27

def to_expression
  return if child_nodes.empty?

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