Class: Wonkavision::EventBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/wonkavision/event_binding.rb

Direct Known Subclasses

Plugins::BusinessActivity::EventBinding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, handler, *args) ⇒ EventBinding

Returns a new instance of EventBinding.



6
7
8
9
10
11
12
13
14
# File 'lib/wonkavision/event_binding.rb', line 6

def initialize(name,handler,*args)
  args.flatten!
  @options = args.extract_options!
  @handler = handler
  @name = name
  @events = []
  args = [@name] if args.blank? || args.flatten.blank?
  @events = args.flatten.map{|evt_name|@handler.event_path(evt_name)}
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



4
5
6
# File 'lib/wonkavision/event_binding.rb', line 4

def events
  @events
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/wonkavision/event_binding.rb', line 4

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/wonkavision/event_binding.rb', line 4

def options
  @options
end

Instance Method Details

#subscribe_to_events(&block) ⇒ Object



16
17
18
19
20
# File 'lib/wonkavision/event_binding.rb', line 16

def subscribe_to_events(&block)
  @events.each do |event|
    Wonkavision.event_coordinator.subscribe(event,&block)
  end
end