No release in over 3 years
Low commit activity in last 3 years
ActiveRecord with default values
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2
 Project Readme

Build Status Dependency Status Scrutinizer Code Quality Coverage Status

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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request