class HecksAdapters::DynamoDB::Commands::Update
Attributes
attributes[R]
client[R]
head[R]
Public Class Methods
new(id, attributes, head, client)
click to toggle source
# File lib/commands/update.rb, line 6 def initialize(id, attributes, head, client) @head = head @attributes = attributes @client = client @id = id end
Public Instance Methods
call()
click to toggle source
# File lib/commands/update.rb, line 13 def call update_item self end
Private Instance Methods
update_item()
click to toggle source
# File lib/commands/update.rb, line 22 def update_item update_expression = "SET " + @attributes.map{|a| "##{a[0].upcase} = :#{a[0]}"}.join(", ") attribute_names = @attributes.map{|a| ["##{a[0].upcase}", a[0].to_s]}.to_h attribute_values = @attributes.map{|a| [":#{a[0]}", a[1]]}.to_h client.update_item( expression_attribute_names: attribute_names, expression_attribute_values: attribute_values, table_name: @head.name, key: { id: @id }, return_values: "ALL_NEW", update_expression: update_expression ) end