提交 6d7a8267 编写于 作者: N Nicholas Rowe

Documentation: Added small comments to Observering module

上级 2a75c190
......@@ -48,6 +48,7 @@ def instantiate_observers
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 @@ def add_observer(observer)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册