Skip to content
It provides the useful methods for increment or decrement.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
rails
test
MIT-LICENSE
README.md
Rakefile
init.rb

README.md

IncrementFu

It provides the useful methods for increment or decrement.

Example

schema:

create_table :foos do |t|
  t.integer  :bar
  t.integer  :baz
end

model:

class Foo < ActiveRecord::Base
  increment_fu :bar, :min => 0, :max => 10
  increment_fu :baz, :min => lambda { |f| f.bar - 10 }, :max => lambda { |f| f.bar + 10 }
end

usage:

foo = Foo.create(:bar => 0, :baz => 0)
p foo.bar # => 0
foo.increment_bar
p foo.bar # => 1
foo.increment_bar(10)
p foo.bar # => 10

Copyright (c) 2010 jugyo, released under the MIT license

Something went wrong with that request. Please try again.