Class: TwiStream::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/twistream/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (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