Class: DynamoidAdvancedWhere::Nodes::ArrayLiteralNode
- Inherits:
-
Object
- Object
- DynamoidAdvancedWhere::Nodes::ArrayLiteralNode
- Defined in:
- lib/dynamoid_advanced_where/nodes/array_literal_node.rb
Instance Attribute Summary collapse
-
#attr_prefix ⇒ Object
Returns the value of attribute attr_prefix.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #expression_attribute_names ⇒ Object
- #expression_attribute_values ⇒ Object
-
#initialize(value) ⇒ ArrayLiteralNode
constructor
A new instance of ArrayLiteralNode.
- #to_expression ⇒ Object
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_prefix ⇒ Object
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 |
#value ⇒ Object
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_names ⇒ Object
23 24 25 |
# File 'lib/dynamoid_advanced_where/nodes/array_literal_node.rb', line 23 def expression_attribute_names {} end |
#expression_attribute_values ⇒ Object
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_expression ⇒ Object
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 |