mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Documentation: Added small comments to Observering module
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user