aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-02-13 09:00:59 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-13 09:00:59 -0800
commit9bcfb1a9745d5fafbbd95f78df0819f2e842d2d4 (patch)
tree83701c182c5a48aa149c05eeb6286b6aee1fcb7b
parent804135be91130dab97fd33efdbe550898403db9b (diff)
parenta3a1a6f9ed8db027be25ad392639a3981c50b005 (diff)
downloadrails-9bcfb1a9745d5fafbbd95f78df0819f2e842d2d4.tar.gz
rails-9bcfb1a9745d5fafbbd95f78df0819f2e842d2d4.tar.bz2
rails-9bcfb1a9745d5fafbbd95f78df0819f2e842d2d4.zip
Merge pull request #5018 from hammerdr/issue-4659-docs
Adding documentation to clarify usage of attributes hash.
-rw-r--r--activemodel/lib/active_model/serialization.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb
index f7b1880ed9..51f078e662 100644
--- a/activemodel/lib/active_model/serialization.rb
+++ b/activemodel/lib/active_model/serialization.rb
@@ -17,7 +17,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
- # {'name' => name}
+ # {'name' => nil}
# end
#
# end
@@ -29,8 +29,11 @@ module ActiveModel
# person.name = "Bob"
# person.serializable_hash # => {"name"=>"Bob"}
#
- # You need to declare some sort of attributes hash which contains the attributes
- # you want to serialize and their current value.
+ # You need to declare an attributes hash which contains the attributes
+ # you want to serialize. When called, serializable hash will use
+ # instance methods that match the name of the attributes hash's keys.
+ # In order to override this behavior, take a look at the private
+ # method read_attribute_for_serialization.
#
# Most of the time though, you will want to include the JSON or XML
# serializations. Both of these modules automatically include the
@@ -47,7 +50,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
- # {'name' => name}
+ # {'name' => nil}
# end
#
# end