aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-10-21 19:46:10 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-10-21 19:46:10 -0500
commit1e5a6c7855e6ce7d5a9c4c53a326488bd0e3fb08 (patch)
tree9736d3d8663accab8cb5dd7c8151c7b24dd5fe87 /activerecord/lib/active_record
parentbc3f960c0f3b3d88f024969f4606317040cb2332 (diff)
downloadrails-1e5a6c7855e6ce7d5a9c4c53a326488bd0e3fb08.tar.gz
rails-1e5a6c7855e6ce7d5a9c4c53a326488bd0e3fb08.tar.bz2
rails-1e5a6c7855e6ce7d5a9c4c53a326488bd0e3fb08.zip
add docs to AR::AttributeMethods::BeforeTypeCast [ci skip]
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods/before_type_cast.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
index 7fe5411a3b..faee99ccd1 100644
--- a/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
+++ b/activerecord/lib/active_record/attribute_methods/before_type_cast.rb
@@ -1,5 +1,28 @@
module ActiveRecord
module AttributeMethods
+ # = Active Record Attribute Methods Before Type Cast
+ #
+ # <tt>ActiveRecord::AttributeMethods::BeforeTypeCast</tt> provides a way to
+ # read the value of the attributes before typecasting and deserialization.
+ #
+ # class Task < ActiveRecord::Base
+ # end
+ #
+ # task = Task.new(id: '1', completed_on: '2012-10-21')
+ # task.id # => 1
+ # task.completed_on # => Sun, 21 Oct 2012
+ #
+ # task.attributes_before_type_cast
+ # # => {"id"=>"1", "completed_on"=>"2012-10-21", ... }
+ # task.read_attribute_before_type_cast('id') # => 1
+ # task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
+ #
+ # In addition to #read_attribute_before_type_cast and #attributes_before_type_cast,
+ # it declares a method for all attributes with the <tt>*_before_type_cast</tt>
+ # suffix.
+ #
+ # task.id_before_type_cast # => "1"
+ # task.completed_on_before_type_cast # => "2012-10-21"
module BeforeTypeCast
extend ActiveSupport::Concern