Class: Slack::Registry
- Inherits:
-
Object
- Object
- Slack::Registry
- Defined in:
- lib/laziness/registry.rb
Instance Attribute Summary collapse
-
#observers ⇒ Object
readonly
Returns the value of attribute observers.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #notify(topic, *args) ⇒ Object
- #register(topic = nil, observer = nil, func = :update, &blk) ⇒ Object
- #unregister(topic = nil, observer = nil, func = :update, &blk) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
5 6 7 |
# File 'lib/laziness/registry.rb', line 5 def initialize @observers = [] end |
Instance Attribute Details
#observers ⇒ Object (readonly)
Returns the value of attribute observers.
3 4 5 |
# File 'lib/laziness/registry.rb', line 3 def observers @observers end |
Instance Method Details
#clear ⇒ Object
9 10 11 |
# File 'lib/laziness/registry.rb', line 9 def clear observers.clear end |
#notify(topic, *args) ⇒ Object
13 14 15 |
# File 'lib/laziness/registry.rb', line 13 def notify(topic, *args) observers.select { |o| o.topic == topic }.map { |o| o.execute(*args) } end |