| 643 | | # Specifies that the attribute by the name of +attr_name+ should be serialized before saving to the database and unserialized |
|---|
| 644 | | # after loading from the database. The serialization is done through YAML. If +class_name+ is specified, the serialized |
|---|
| 645 | | # object must be of that class on retrieval, or nil. Otherwise, +SerializationTypeMismatch+ will be raised. |
|---|
| | 643 | # If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, |
|---|
| | 644 | # then specify the name of that attribute using this method and it will be handled automatically. |
|---|
| | 645 | # The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that |
|---|
| | 646 | # class on retrieval or +SerializationTypeMismatch+ will be raised. |
|---|
| | 647 | # |
|---|
| | 648 | # ==== Options |
|---|
| | 649 | # |
|---|
| | 650 | # +attr_name+ The field name that should be serialized |
|---|
| | 651 | # +class_name+ Optional, class name that the object should be equal to |
|---|
| | 652 | # |
|---|
| | 653 | # ==== Example |
|---|
| | 654 | # # Serialize a preferences attribute |
|---|
| | 655 | # class User |
|---|
| | 656 | # serialize :preferences |
|---|
| | 657 | # end |
|---|