From 9f3637fad5bb68b13a6d004694ba8d2b5e6b8d9d Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 00:33:26 -0500 Subject: adding observer example --- activemodel/README.rdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index 1fd75141f8..0c7089598c 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -135,6 +135,16 @@ behavior out of the box: pattern in a Rails App and take advantage of all the standard observer functions. + class PersonObserver < ActiveModel::Observer + def after_create(person) + person.logger.info("New person added!") + end + + def after_destroy(person) + person.logger.warn("Person with an id of #{person.id} was destroyed!") + end + end + {Learn more}[link:classes/ActiveModel/Observer.html] * Making objects serializable -- cgit v1.2.3 From c962680e1902d2c9474f0be8ba7b0b8ab361cae6 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 00:40:00 -0500 Subject: fixing active model links in readme --- activemodel/README.rdoc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index 0c7089598c..1485709991 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -53,7 +53,7 @@ behavior out of the box: person.clear_name person.clear_age - {Learn more}[link:classes/ActiveModel/AttributeMethods.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html] * Callbacks for certain operations @@ -71,7 +71,7 @@ behavior out of the box: This generates +before_create+, +around_create+ and +after_create+ class methods that wrap your create method. - {Learn more}[link:classes/ActiveModel/Callbacks.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Callbacks.html] * Tracking value changes @@ -88,7 +88,7 @@ behavior out of the box: person.save person.previous_changes # => {'name' => ['bob, 'robert']} - {Learn more}[link:classes/ActiveModel/Dirty.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Dirty.html] * Adding +errors+ interface to objects @@ -116,7 +116,7 @@ behavior out of the box: person.errors.full_messages # => ["Name can not be nil"] - {Learn more}[link:classes/ActiveModel/Errors.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Errors.html] * Model name introspection @@ -127,7 +127,7 @@ behavior out of the box: NamedPerson.model_name # => "NamedPerson" NamedPerson.model_name.human # => "Named person" - {Learn more}[link:classes/ActiveModel/Naming.html] + {Learn more}[http://api.rubyonrails.org/ActiveModel/Naming.html] * Observer support @@ -145,7 +145,7 @@ behavior out of the box: end end - {Learn more}[link:classes/ActiveModel/Observer.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Observer.html] * Making objects serializable @@ -157,7 +157,7 @@ behavior out of the box: s.to_json # => "{\"name\":null}" s.to_xml # => "\n "My attribute" - {Learn more}[link:classes/ActiveModel/Translation.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Translation.html] * Validation support @@ -186,7 +186,7 @@ behavior out of the box: person.first_name = 'zoolander' person.valid? # => false - {Learn more}[link:classes/ActiveModel/Validations.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Validations.html] * Custom validators @@ -208,7 +208,7 @@ behavior out of the box: p.name = "Bob" p.valid? # => true - {Learn more}[link:classes/ActiveModel/Validator.html] + {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Validator.html] == Download and installation -- cgit v1.2.3 From 79f1daf2cef87c706cdaa98398de3e5cf401e839 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 00:45:54 -0500 Subject: marking some active model classes --- activemodel/README.rdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index 1485709991..b8c7846c1d 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -75,7 +75,7 @@ behavior out of the box: * Tracking value changes - The ActiveModel::Dirty module allows for tracking attribute changes: + The +ActiveModel::Dirty+ module allows for tracking attribute changes: person = Person.new person.name # => nil @@ -131,7 +131,7 @@ behavior out of the box: * Observer support - ActiveModel::Observers allows your object to implement the Observer + +ActiveModel::Observers+ allows your object to implement the Observer pattern in a Rails App and take advantage of all the standard observer functions. @@ -149,7 +149,7 @@ behavior out of the box: * Making objects serializable - ActiveModel::Serialization provides a standard interface for your object + +ActiveModel::Serialization+ provides a standard interface for your object to provide +to_json+ or +to_xml+ serialization. s = SerialPerson.new -- cgit v1.2.3 From 204a79fe61051dac19ac854f22f22ca4288162b8 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 00:48:19 -0500 Subject: fixing marked actived model classes in readme --- activemodel/README.rdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index b8c7846c1d..df9ca93051 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -75,7 +75,7 @@ behavior out of the box: * Tracking value changes - The +ActiveModel::Dirty+ module allows for tracking attribute changes: + The ActiveModel::Dirty module allows for tracking attribute changes: person = Person.new person.name # => nil @@ -131,7 +131,7 @@ behavior out of the box: * Observer support - +ActiveModel::Observers+ allows your object to implement the Observer + ActiveModel::Observers allows your object to implement the Observer pattern in a Rails App and take advantage of all the standard observer functions. @@ -149,7 +149,7 @@ behavior out of the box: * Making objects serializable - +ActiveModel::Serialization+ provides a standard interface for your object + ActiveModel::Serialization provides a standard interface for your object to provide +to_json+ or +to_xml+ serialization. s = SerialPerson.new -- cgit v1.2.3 From ae0a4ca2e16ff055883f38abb3999b303ba3295c Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 7 May 2012 09:49:54 -0500 Subject: removing the surrounding +s in active model readme --- activemodel/README.rdoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index df9ca93051..1485709991 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -75,7 +75,7 @@ behavior out of the box: * Tracking value changes - The ActiveModel::Dirty module allows for tracking attribute changes: + The ActiveModel::Dirty module allows for tracking attribute changes: person = Person.new person.name # => nil @@ -131,7 +131,7 @@ behavior out of the box: * Observer support - ActiveModel::Observers allows your object to implement the Observer + ActiveModel::Observers allows your object to implement the Observer pattern in a Rails App and take advantage of all the standard observer functions. @@ -149,7 +149,7 @@ behavior out of the box: * Making objects serializable - ActiveModel::Serialization provides a standard interface for your object + ActiveModel::Serialization provides a standard interface for your object to provide +to_json+ or +to_xml+ serialization. s = SerialPerson.new -- cgit v1.2.3 From 700dd0014b8c19651650923dff28912e7d3607b9 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Mon, 7 May 2012 20:43:04 +0530 Subject: Revert "fixing active model links in readme" This reverts commit c962680e1902d2c9474f0be8ba7b0b8ab361cae6. Reason: The links must be relative to work in both edge and stable api sites. --- activemodel/README.rdoc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'activemodel/README.rdoc') diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc index 1485709991..0c7089598c 100644 --- a/activemodel/README.rdoc +++ b/activemodel/README.rdoc @@ -53,7 +53,7 @@ behavior out of the box: person.clear_name person.clear_age - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/AttributeMethods.html] + {Learn more}[link:classes/ActiveModel/AttributeMethods.html] * Callbacks for certain operations @@ -71,7 +71,7 @@ behavior out of the box: This generates +before_create+, +around_create+ and +after_create+ class methods that wrap your create method. - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Callbacks.html] + {Learn more}[link:classes/ActiveModel/Callbacks.html] * Tracking value changes @@ -88,7 +88,7 @@ behavior out of the box: person.save person.previous_changes # => {'name' => ['bob, 'robert']} - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Dirty.html] + {Learn more}[link:classes/ActiveModel/Dirty.html] * Adding +errors+ interface to objects @@ -116,7 +116,7 @@ behavior out of the box: person.errors.full_messages # => ["Name can not be nil"] - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Errors.html] + {Learn more}[link:classes/ActiveModel/Errors.html] * Model name introspection @@ -127,7 +127,7 @@ behavior out of the box: NamedPerson.model_name # => "NamedPerson" NamedPerson.model_name.human # => "Named person" - {Learn more}[http://api.rubyonrails.org/ActiveModel/Naming.html] + {Learn more}[link:classes/ActiveModel/Naming.html] * Observer support @@ -145,7 +145,7 @@ behavior out of the box: end end - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Observer.html] + {Learn more}[link:classes/ActiveModel/Observer.html] * Making objects serializable @@ -157,7 +157,7 @@ behavior out of the box: s.to_json # => "{\"name\":null}" s.to_xml # => "\n "My attribute" - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Translation.html] + {Learn more}[link:classes/ActiveModel/Translation.html] * Validation support @@ -186,7 +186,7 @@ behavior out of the box: person.first_name = 'zoolander' person.valid? # => false - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Validations.html] + {Learn more}[link:classes/ActiveModel/Validations.html] * Custom validators @@ -208,7 +208,7 @@ behavior out of the box: p.name = "Bob" p.valid? # => true - {Learn more}[http://api.rubyonrails.org/classes/ActiveModel/Validator.html] + {Learn more}[link:classes/ActiveModel/Validator.html] == Download and installation -- cgit v1.2.3