Class: Dynamoid::Persistence::UpdateFields
- Inherits:
-
Object
- Object
- Dynamoid::Persistence::UpdateFields
- Defined in:
- lib/dynamoid/persistence/update_fields.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(model_class, partition_key:, sort_key:, attributes:, conditions:) ⇒ UpdateFields
constructor
A new instance of UpdateFields.
Constructor Details
#initialize(model_class, partition_key:, sort_key:, attributes:, conditions:) ⇒ UpdateFields
Returns a new instance of UpdateFields.
11 12 13 14 15 16 17 |
# File 'lib/dynamoid/persistence/update_fields.rb', line 11 def initialize(model_class, partition_key:, sort_key:, attributes:, conditions:) @model_class = model_class @partition_key = partition_key @sort_key = sort_key @attributes = attributes.symbolize_keys @conditions = conditions end |
Class Method Details
.call(*args, **options) ⇒ Object
7 8 9 |
# File 'lib/dynamoid/persistence/update_fields.rb', line 7 def self.call(*args, **) new(*args, **).call end |
Instance Method Details
#call ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dynamoid/persistence/update_fields.rb', line 19 def call UpdateValidations.validate_attributes_exist(@model_class, @attributes) if @model_class. @attributes[:updated_at] ||= DateTime.now.in_time_zone(Time.zone) end raw_attributes = update_item @model_class.new(undump_attributes(raw_attributes)) rescue Dynamoid::Errors::ConditionalCheckFailedException end |