diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-09-21 22:47:08 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-09-21 22:47:37 -0500 |
commit | c57064a8ab22906cc3f5b4cc6845ac5e1e1a384d (patch) | |
tree | 741ee0dc233f62a33288324e80802adc69036399 /activerecord/lib/active_record/attribute_methods/serialization.rb | |
parent | fe78e1dad6af88a08715abcad0e6e4e2d5c9b262 (diff) | |
download | rails-c57064a8ab22906cc3f5b4cc6845ac5e1e1a384d.tar.gz rails-c57064a8ab22906cc3f5b4cc6845ac5e1e1a384d.tar.bz2 rails-c57064a8ab22906cc3f5b4cc6845ac5e1e1a384d.zip |
update AR/attribute_methods documentation [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/serialization.rb')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/serialization.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/serialization.rb b/activerecord/lib/active_record/attribute_methods/serialization.rb index bdda5bc009..d2cfcbbaf8 100644 --- a/activerecord/lib/active_record/attribute_methods/serialization.rb +++ b/activerecord/lib/active_record/attribute_methods/serialization.rb @@ -4,17 +4,19 @@ module ActiveRecord extend ActiveSupport::Concern included do - # Returns a hash of all the attributes that have been specified for serialization as - # keys and their class restriction as values. + # Returns a hash of all the attributes that have been specified for + # serialization as keys and their class restriction as values. class_attribute :serialized_attributes, instance_accessor: false self.serialized_attributes = {} end module ClassMethods - # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, - # then specify the name of that attribute using this method and it will be handled automatically. - # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that - # class on retrieval or SerializationTypeMismatch will be raised. + # If you have an attribute that needs to be saved to the database as an + # object, and retrieved as the same object, then specify the name of that + # attribute using this method and it will be handled automatically. The + # serialization is done through YAML. If +class_name+ is specified, the + # serialized object must be of that class on retrieval or + # <tt>SerializationTypeMismatch</tt> will be raised. # # ==== Parameters # @@ -22,7 +24,8 @@ module ActiveRecord # * +class_name+ - Optional, class name that the object type should be equal to. # # ==== Example - # # Serialize a preferences attribute + # + # # Serialize a preferences attribute. # class User < ActiveRecord::Base # serialize :preferences # end @@ -60,7 +63,7 @@ module ActiveRecord end end - class Attribute < Struct.new(:coder, :value, :state) + class Attribute < Struct.new(:coder, :value, :state) # :nodoc: def unserialized_value state == :serialized ? unserialize : value end |