Sha256: 5042654d33477cce0982410dd5ef0e7978a24328260acbae27aa1f90b49624da
Contents?: true
Size: 664 Bytes
Versions: 1
Compression:
Stored size: 664 Bytes
Contents
require 'active_support/core_ext/object/blank' module Slatan ## class to Event Dispatching for concerns module Ear @concerns = [] class << self ## register subscriber # @param concern subscriber # @param options option # cond: <Kernel.#lambda> call hear method of concern if cond.call(msg) is true def register(concern, options={}) @concerns << [concern, options[:cond]] end ## publish to subscribers def hear(msg) @concerns.each do |concern, cond| if cond.blank? || cond.call(msg) concern.hear(msg) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slatan-0.1.0 | lib/slatan/ear.rb |