Class: Slack::Observer
- Inherits:
-
Object
- Object
- Slack::Observer
- Defined in:
- lib/laziness/observer.rb
Instance Attribute Summary collapse
-
#blk ⇒ Object
readonly
Returns the value of attribute blk.
-
#func ⇒ Object
readonly
Returns the value of attribute func.
-
#observer ⇒ Object
readonly
Returns the value of attribute observer.
-
#topic ⇒ Object
Returns the value of attribute topic.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #execute(*args) ⇒ Object
-
#initialize(topic = nil, observer = nil, func = :update, &blk) ⇒ Observer
constructor
A new instance of Observer.
Constructor Details
#initialize(topic = nil, observer = nil, func = :update, &blk) ⇒ Observer
Returns a new instance of Observer.
6 7 8 9 10 11 |
# File 'lib/laziness/observer.rb', line 6 def initialize(topic=nil, observer=nil, func=:update, &blk) @topic = topic @observer = observer @func = func @blk = blk end |
Instance Attribute Details
#blk ⇒ Object (readonly)
Returns the value of attribute blk.
4 5 6 |
# File 'lib/laziness/observer.rb', line 4 def blk @blk end |
#func ⇒ Object (readonly)
Returns the value of attribute func.
4 5 6 |
# File 'lib/laziness/observer.rb', line 4 def func @func end |
#observer ⇒ Object (readonly)
Returns the value of attribute observer.
4 5 6 |
# File 'lib/laziness/observer.rb', line 4 def observer @observer end |
#topic ⇒ Object
Returns the value of attribute topic.
3 4 5 |
# File 'lib/laziness/observer.rb', line 3 def topic @topic end |
Instance Method Details
#==(other) ⇒ Object
18 19 20 21 22 |
# File 'lib/laziness/observer.rb', line 18 def ==(other) return false if other.nil? self.topic == other.topic && self.blk == other.blk && self.observer == other.observer && self.func == other.func end |
#execute(*args) ⇒ Object
13 14 15 16 |
# File 'lib/laziness/observer.rb', line 13 def execute(*args) blk.call(*args) if blk observer.send func, *args if observer && observer.respond_to?(func) end |