Class: Dynamoid::Transactions::Mutation::Builders::DeleteRequestBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_class) ⇒ DeleteRequestBuilder

Returns a new instance of DeleteRequestBuilder.



11
12
13
14
15
16
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 11

def initialize(model_class)
  @model_class = model_class
  @condition_expression = nil
  @extra_attribute_names = {}
  @extra_attribute_values = {}
end

Instance Attribute Details

#condition_expression=(value) ⇒ Object (writeonly)

Sets the attribute condition_expression

Parameters:

  • value

    the value to set the attribute condition_expression to.



9
10
11
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 9

def condition_expression=(value)
  @condition_expression = value
end

#hash_key=(value) ⇒ Object (writeonly)

Sets the attribute hash_key

Parameters:

  • value

    the value to set the attribute hash_key to.



9
10
11
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 9

def hash_key=(value)
  @hash_key = value
end

#range_key=(value) ⇒ Object (writeonly)

Sets the attribute range_key

Parameters:

  • value

    the value to set the attribute range_key to.



9
10
11
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 9

def range_key=(value)
  @range_key = value
end

Instance Method Details

#add_expression_attribute_name(placeholder, name) ⇒ Object



18
19
20
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 18

def add_expression_attribute_name(placeholder, name)
  @extra_attribute_names[placeholder] = name
end

#add_expression_attribute_value(placeholder, value) ⇒ Object



22
23
24
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 22

def add_expression_attribute_value(placeholder, value)
  @extra_attribute_values[placeholder] = value
end

#requestObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dynamoid/transactions/mutation/builders/delete_request_builder.rb', line 26

def request
  key = { @model_class.hash_key => @hash_key }
  key[@model_class.range_key] = @range_key if @model_class.range_key?

  {
    delete: {
      key: key,
      table_name: @model_class.table_name,
      expression_attribute_names: @extra_attribute_names.presence,
      expression_attribute_values: @extra_attribute_values.presence,
      condition_expression: @condition_expression
    }.compact
  }
end