Sha256: f620bcabea47d482bc9ee9a5c94eb6277d03a2af1f0f8b4f22682816b2d87ba0

Contents?: true

Size: 349 Bytes

Versions: 2

Compression:

Stored size: 349 Bytes

Contents

class Counter < ActiveRecord::Base
  belongs_to :owner, :polymorphic => true
  
  def increment!
    set count + 1
  end
  
  def increment_by!(value)
    set count + value
  end
  
  def decrement!
    set count - 1
  end
  
  def decrement_by!(value)
    set count - value
  end
  
  def set(value)
    update_attributes! :count => value
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
adva_cms-0.0.1 vendor/gems/has_counter/lib/counter.rb
adva-0.0.1 adva_cms/vendor/gems/has_counter/lib/counter.rb