class Slack::Registry
Attributes
observers[R]
Public Class Methods
new()
click to toggle source
# File lib/laziness/registry.rb, line 5 def initialize @observers = [] end
Public Instance Methods
clear()
click to toggle source
# File lib/laziness/registry.rb, line 9 def clear observers.clear end
notify(topic, *args)
click to toggle source
# File lib/laziness/registry.rb, line 13 def notify(topic, *args) observers.select { |o| o.topic == topic }.map { |o| o.execute(*args) } end
register(topic=nil, observer=nil, func=:update, &blk)
click to toggle source
# File lib/laziness/registry.rb, line 17 def register(topic=nil, observer=nil, func=:update, &blk) observers << Observer.new(topic, observer, func, &blk) end
unregister(topic=nil, observer=nil, func=:update, &blk)
click to toggle source
# File lib/laziness/registry.rb, line 21 def unregister(topic=nil, observer=nil, func=:update, &blk) observers.delete Observer.new(topic, observer, func, &blk) end