From 6d7a8267b98b0ffc5f1b45c0a35ba0548f2084e8 Mon Sep 17 00:00:00 2001 From: Nicholas Rowe Date: Sun, 20 Feb 2011 21:05:41 -0500 Subject: Documentation: Added small comments to Observering module --- activemodel/lib/active_model/observing.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index dde3a882cf..f09bdca9d1 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -48,6 +48,7 @@ module ActiveModel observers.each { |o| instantiate_observer(o) } end + # Add a new Observer to the pool def add_observer(observer) unless observer.respond_to? :update raise ArgumentError, "observer needs to respond to `update'" @@ -55,12 +56,14 @@ module ActiveModel observer_instances << observer end + # Notify list of observers of a change def notify_observers(*arg) for observer in observer_instances observer.update(*arg) end end + # Total number of observers def count_observers observer_instances.size end -- cgit v1.2.3