Sha256: eb13ee63347f10488d033226347027bdf8fa4a90f922636df56187af29da43d6

Contents?: true

Size: 336 Bytes

Versions: 6

Compression:

Stored size: 336 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! count: value
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
adva_comments-0.2.0 vendor/gems/has_counter/lib/counter.rb
adva-0.1.4 vendor/gems/has_counter/lib/counter.rb
adva-0.1.3 vendor/gems/has_counter/lib/counter.rb
adva-0.1.2 vendor/gems/has_counter/lib/counter.rb
adva-0.1.1 vendor/gems/has_counter/lib/counter.rb
adva-0.1.0 vendor/gems/has_counter/lib/counter.rb