Class: DynamoidAdvancedWhere::Nodes::ArrayLiteralNode

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamoid_advanced_where/nodes/array_literal_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ArrayLiteralNode

Returns a new instance of ArrayLiteralNode.



10
11
12
13
14
# File 'lib/dynamoid_advanced_where/nodes/array_literal_node.rb', line 10

def initialize(value)
  self.value = value
  self.attr_prefix = SecureRandom.hex
  freeze
end

Instance Attribute Details

#attr_prefixObject

Returns the value of attribute attr_prefix.



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

def attr_prefix
  @attr_prefix
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#expression_attribute_namesObject



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

def expression_attribute_names
  {}
end

#expression_attribute_valuesObject



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

def expression_attribute_values
  value.each_with_index.map do |val, idx|
    [":#{attr_prefix}#{idx}", val]
  end.to_h
end

#to_expressionObject



16
17
18
19
20
21
# File 'lib/dynamoid_advanced_where/nodes/array_literal_node.rb', line 16

def to_expression
  values = value.each_with_index.map do |_, idx|
    ":#{attr_prefix}#{idx}"
  end
  "(#{values.join(', ')})"
end