Sha256: e582212fb0e98aebdd3c02fc04c32d6bb8c8d5e6422fa2b65c17ba4c07507e09

Contents?: true

Size: 953 Bytes

Versions: 2

Compression:

Stored size: 953 Bytes

Contents

require 'default_values/version'
require 'default_values/dsl'
require 'default_values/railtie' if defined?(Rails)

#
# = ActiveRecord::DefaultValue
# initialize with default_values
#
# == sample
# you can specify default values with hash:
#
#  class Book < ActiveRecord::Base
#    default_values rating: 'r18', type: 'comic'
#  end
#
#  book = Book.new
#  book.rating # => "r18"
#  book.type # => "comic"
#  book.title # => nil
#
# you can use instance values with lambda:
#  class Book < ActiveRecord::Base
#    default_values type: 'comic', released_at: lambda { Time.now }
#  end
#
# or with block:
#  class Book < ActiveRecord::Base
#    default_values type: 'comic' do
#      t = Time.now
#      {released_at: t, edition_updated_at: t}
#    end
#  end
#
#  book1 = Book.new
#  # wait 10 sec
#  book2 = Book.new
#  book1.release_at == book2.release_at # => false
#  book1.released_at == book1.edition_updated_at # => true
#
module DefaultValues
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ar_default_values-0.5.2 lib/default_values.rb
ar_default_values-0.5.1 lib/default_values.rb