module Moneta::IncrementSupport

@api private

Public Class Methods

included(base) click to toggle source
# File lib/moneta/increment_support.rb, line 12
def self.included(base)
  base.supports(:increment) if base.respond_to?(:supports)
end

Public Instance Methods

increment(key, amount = 1, options = {}) click to toggle source

(see Defaults#increment)

# File lib/moneta/increment_support.rb, line 5
def increment(key, amount = 1, options = {})
  existing = load(key, options)
  value = (existing == nil ? 0 : Integer(existing)) + amount
  store(key, value.to_s, options)
  value
end