Module: Moneta::Mixins::IncrementSupport Private

Included in:
Adapters::File, Adapters::LRUHash, Adapters::Memory, Adapters::Sqlite
Defined in:
lib/moneta/mixins.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#increment(key, amount = 1, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
31
32
33
34
35
# File 'lib/moneta/mixins.rb', line 28

def increment(key, amount = 1, options = {})
  value = load(key, options)
  intvalue = value.to_i
  raise 'Tried to increment non integer value' unless value == nil || intvalue.to_s == value.to_s
  intvalue += amount
  store(key, intvalue.to_s, options)
  intvalue
end