Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding documentation to clarify usage of attributes hash. #5018

Merged
merged 2 commits into from Feb 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions activemodel/lib/active_model/serialization.rb
Expand Up @@ -17,7 +17,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
# {'name' => name}
# {'name' => nil}
# end
#
# end
Expand All @@ -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
Expand All @@ -47,7 +50,7 @@ module ActiveModel
# attr_accessor :name
#
# def attributes
# {'name' => name}
# {'name' => nil}
# end
#
# end
Expand Down