class Commutator::Expressions::ProjectionExpression

See: goo.gl/bOKUjK

Constructs composable ProjectionExpression for use in DynamoDB API calls. Call to_s when sending to DynamoDB.

Note: path passes its arguments to the Statement constructor. Read the docs there for placeholder syntax.

Usage: exp = Commutator::Expressions::ProjectionExpression.new

.path('token_channel')
.path('ts.items[2]')
.path('#?', names: ['count'])
.path('#?.hey', names: ['size'])

Later…

exp.path(‘another_one’)

The expression above would produce the following with ‘to_s`

“token_channel, ts.items, NAME_d61a1061060c9e9691027c42d6766b90,

#NAME_1eb3b08a347050ee467a2e24e6c15349.hey, another_one"

Attributes

attribute_names[R]

Public Class Methods

new(attribute_names: nil, &block) click to toggle source
# File lib/commutator/expressions/projection_expression.rb, line 30
def initialize(attribute_names: nil, &block)
  @attribute_names = attribute_names || AttributeNames.new
end

Public Instance Methods

path(p, names: []) click to toggle source
# File lib/commutator/expressions/projection_expression.rb, line 38
def path(p, names: [])
  names.each { |n| attribute_names.add(n) }
  statements << Statement.new(p, names: names)

  self
end
statements() click to toggle source
# File lib/commutator/expressions/projection_expression.rb, line 34
def statements
  @statements ||= []
end
to_s() click to toggle source
# File lib/commutator/expressions/projection_expression.rb, line 45
def to_s
  statements.join(', ')
end