DefaultValues
initialize with default_values
Installation
Add this line to your application's Gemfile:
gem 'ar_default_values'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ar_default_values
Usage
you can specify default values with hash:
class Book < ActiveRecord::Base
default_values rating: 'r18', type: 'comic' do
t = Time.now
{ :released_at => t, :edition_updated_at => t }
end
end
book = Book.new
book.rating # => "r18"
book.type # => "comic"
book.title # => nil
book.released_at == book.edition_updated_at # => true
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request