aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activemodel/README.rdoc16
1 files changed, 15 insertions, 1 deletions
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index fc34d69ff6..4adb43a015 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -75,7 +75,11 @@ behavior out of the box:
* Tracking value changes
- The ActiveModel::Dirty module allows for tracking attribute changes:
+ class Person
+ include ActiveModel::Dirty
+
+ attr_accessor :name
+ end
person = Person.new
person.name # => nil
@@ -152,6 +156,16 @@ behavior out of the box:
ActiveModel::Serialization provides a standard interface for your object
to provide +to_json+ or +to_xml+ serialization.
+ class SerialPerson
+ include ActiveModel::Serialization
+
+ attr_accessor :name
+
+ def attributes
+ {'name' => name}
+ end
+ end
+
s = SerialPerson.new
s.serializable_hash # => {"name"=>nil}
s.to_json # => "{\"name\":null}"