aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-01-17 19:12:12 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-01-17 19:12:12 +1100
commite6063282f98b9d40da00897727e5ae01ca61b9fc (patch)
treece711a9468002f457569b805e2f8081b90e9f73a
parentfbc7c2beca0433d4b070e3292a1009a94987d5c0 (diff)
downloadrails-e6063282f98b9d40da00897727e5ae01ca61b9fc.tar.gz
rails-e6063282f98b9d40da00897727e5ae01ca61b9fc.tar.bz2
rails-e6063282f98b9d40da00897727e5ae01ca61b9fc.zip
Fixing documentation for ActiveModel::Observer
-rw-r--r--activemodel/README8
-rw-r--r--activemodel/lib/active_model/observing.rb21
2 files changed, 21 insertions, 8 deletions
diff --git a/activemodel/README b/activemodel/README
index 710f502aa3..27121d2c03 100644
--- a/activemodel/README
+++ b/activemodel/README
@@ -134,3 +134,11 @@ functionality from the following modules:
{Learn more}[link:classes/ActiveModel/Naming.html]
+* Adding observer support to your objects
+
+ ActiveModel::Observers allows your object to implement the Observer
+ pattern in a Rails App and take advantage of all the standard observer
+ functions.
+
+ {Learn more}[link:classes/ActiveModel/Observer.html]
+ \ No newline at end of file
diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb
index d9d1ab8967..69cb58f41b 100644
--- a/activemodel/lib/active_model/observing.rb
+++ b/activemodel/lib/active_model/observing.rb
@@ -24,8 +24,9 @@ module ActiveModel
# # Same as above, just using explicit class references
# ActiveRecord::Base.observers = Cacher, GarbageCollector
#
- # Note: Setting this does not instantiate the observers yet. +instantiate_observers+ is
- # called during startup, and before each development request.
+ # Note: Setting this does not instantiate the observers yet.
+ # +instantiate_observers+ is called during startup, and before
+ # each development request.
def observers=(*values)
@observers = values.flatten
end
@@ -102,10 +103,12 @@ module ActiveModel
#
# == Observing a class that can't be inferred
#
- # Observers will by default be mapped to the class with which they share a name. So CommentObserver will
- # be tied to observing Comment, ProductManagerObserver to ProductManager, and so on. If you want to name your observer
- # differently than the class you're interested in observing, you can use the Observer.observe class method which takes
- # either the concrete class (Product) or a symbol for that class (:product):
+ # Observers will by default be mapped to the class with which they share a
+ # name. So CommentObserver will be tied to observing Comment, ProductManagerObserver
+ # to ProductManager, and so on. If you want to name your observer differently than
+ # the class you're interested in observing, you can use the Observer.observe class
+ # method which takes either the concrete class (Product) or a symbol for that
+ # class (:product):
#
# class AuditObserver < ActiveModel::Observer
# observe :account
@@ -115,7 +118,8 @@ module ActiveModel
# end
# end
#
- # If the audit observer needs to watch more than one kind of object, this can be specified with multiple arguments:
+ # If the audit observer needs to watch more than one kind of object, this can be
+ # specified with multiple arguments:
#
# class AuditObserver < ActiveModel::Observer
# observe :account, :balance
@@ -125,7 +129,8 @@ module ActiveModel
# end
# end
#
- # The AuditObserver will now act on both updates to Account and Balance by treating them both as records.
+ # The AuditObserver will now act on both updates to Account and Balance by treating
+ # them both as records.
#
class Observer
include Singleton