Class: Commutator::Options::UpdateItem

Inherits:
Object
  • Object
show all
Includes:
Util::Fluent
Defined in:
lib/commutator/options/update_item.rb

Instance Method Summary collapse

Constructor Details

#initializeUpdateItem

Returns a new instance of UpdateItem.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/commutator/options/update_item.rb', line 22

def initialize
  @key = {}

  @expression_attribute_names = Expressions::AttributeNames.new
  @expression_attribute_values = Expressions::AttributeValues.new

  @update_expression = Expressions::UpdateExpression.new(
    attribute_names: @expression_attribute_names,
    attribute_values: @expression_attribute_values)

  @condition_expression = Expressions::ConditionExpression.new(
    attribute_names: @expression_attribute_names,
    attribute_values: @expression_attribute_values)
end

Instance Method Details

#to_hObject Also known as: to_hash



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/commutator/options/update_item.rb', line 37

def to_h
  hash = {
    key: key,
    expression_attribute_names: expression_attribute_names.to_h,
    expression_attribute_values: expression_attribute_values.to_h,
    condition_expression: condition_expression.to_s(wrap: false),
    update_expression: update_expression.to_s,
    return_values: return_values,
    return_consumed_capacity: return_consumed_capacity,
    return_item_collection_metrics: return_item_collection_metrics,
    table_name: table_name
  }

  hash.keep_if { |_key, value| value.present? || value == false }
end