Sha256: c91c8957c66f754955a7f54032edac1b9a0222bcb8820a0a2437b3c13bb2ae9a

Contents?: true

Size: 325 Bytes

Versions: 4

Compression:

Stored size: 325 Bytes

Contents

class Woodhouse::TriggerSet

  def initialize
    @triggers = {}
  end

  def add(event_name, &blk)
    @triggers[event_name.to_sym] ||= []
    @triggers[event_name.to_sym] << blk
  end


  def trigger(event_name, *args)
    (@triggers[event_name.to_sym] || []).each do |trigger|
      trigger.call(*args)
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
woodhouse-1.0.0 lib/woodhouse/trigger_set.rb
woodhouse-0.1.5 lib/woodhouse/trigger_set.rb
woodhouse-0.1.2 lib/woodhouse/trigger_set.rb
woodhouse-0.1.1 lib/woodhouse/trigger_set.rb