Method: Dynamoid::Persistence#decrement

Defined in:
lib/dynamoid/persistence.rb

#decrement(attribute, by = 1) ⇒ Object

Initializes attribute to zero if nil and subtracts the value passed as by (default is 1). Only makes sense for number-based attributes. Returns self.



236
237
238
239
240
# File 'lib/dynamoid/persistence.rb', line 236

def decrement(attribute, by = 1)
  self[attribute] ||= 0
  self[attribute] -= by
  self
end