module CatchBox::Fanout
Public Class Methods
extended(descendant)
click to toggle source
# File lib/catch_box/fanout.rb, line 36 def self.extended(descendant) descendant.class_eval do extend ::Dry::Configurable setting :event, ::CatchBox::Event.new setting :auth, ::CatchBox::Auth.new setting :on, ::CatchBox::On.new setting :emitter, ::CatchBox::Emitter.new @_fanout = [] end end
included(descendant)
click to toggle source
# File lib/catch_box/fanout.rb, line 19 def self.included(descendant) descendant.class_eval do extend ::Dry::Configurable prepend ::CatchBox::Fanout::Initialize setting :event, ::CatchBox::Event.new setting :auth, ::CatchBox::Auth.new setting :on, ::CatchBox::On.new setting :emitter, ::CatchBox::Emitter.new def config self.class.config end end end
Public Instance Methods
all(callable = nil, &block)
click to toggle source
# File lib/catch_box/fanout.rb, line 64 def all(callable = nil, &block) config.on.call( _fanout, nil, callable || block ) end
auth(callable = nil, &block)
click to toggle source
# File lib/catch_box/fanout.rb, line 54 def auth(callable = nil, &block) config.auth.call(callable || block) end
config()
click to toggle source
# File lib/catch_box/fanout.rb, line 30 def config self.class.config end
emit(payload, env)
click to toggle source
# File lib/catch_box/fanout.rb, line 70 def emit(payload, env) config.auth.map(payload, env) pattern = config.event.map(payload) config.emitter.call( _fanout, pattern, payload ) end
event(callable = nil, &block)
click to toggle source
# File lib/catch_box/fanout.rb, line 50 def event(callable = nil, &block) config.event.call(callable || block) end
on(pattern, callable = nil, &block)
click to toggle source
# File lib/catch_box/fanout.rb, line 58 def on(pattern, callable = nil, &block) config.on.call( _fanout, pattern, callable || block ) end
Private Instance Methods
_fanout()
click to toggle source
# File lib/catch_box/fanout.rb, line 82 def _fanout @_fanout end