Class: TwiStream::Event
- Inherits:
-
Object
- Object
- TwiStream::Event
- Defined in:
- lib/twistream/event.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #handle(method = nil, &block) ⇒ Object
-
#initialize(name) ⇒ Event
constructor
A new instance of Event.
- #trigger(*args) ⇒ Object
Constructor Details
#initialize(name) ⇒ Event
Returns a new instance of Event.
5 6 7 |
# File 'lib/twistream/event.rb', line 5 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/twistream/event.rb', line 3 def name @name end |
Instance Method Details
#handle(method = nil, &block) ⇒ Object
9 10 11 12 |
# File 'lib/twistream/event.rb', line 9 def handle(method=nil, & block) @handler = method if method @handler = block if block end |
#trigger(*args) ⇒ Object
14 15 16 |
# File 'lib/twistream/event.rb', line 14 def trigger(* args) @handler.call(* args) if !@handler.nil? end |