module TheCaptain::Events
Constants
- Namespace
- NotificationAdapter
Attributes
adapter[RW]
backend[RW]
event_filter[RW]
event_key_filter[RW]
namespace[RW]
Public Class Methods
all(callable = Proc.new)
click to toggle source
# File lib/the_captain/events.rb, line 17 def all(callable = Proc.new) subscribe(nil, callable) end
configure() { |self| ... }
click to toggle source
# File lib/the_captain/events.rb, line 8 def configure raise ArgumentError, "Must provide a block to configure events" unless block_given? yield self end
instrument(event)
click to toggle source
# File lib/the_captain/events.rb, line 21 def instrument(event) event = event_filter.call(event) return unless event event_key = event_key_filter.call(event) backend.instrument(namespace.call(event_key), event) end
listening?(kit_name)
click to toggle source
# File lib/the_captain/events.rb, line 28 def listening?(kit_name) namespaced_name = namespace.call(kit_name) backend.notifier.listening?(namespaced_name) end
subscribe(kit_name, callable = Proc.new)
click to toggle source
# File lib/the_captain/events.rb, line 13 def subscribe(kit_name, callable = Proc.new) backend.subscribe(namespace.to_regexp(kit_name), adapter.call(callable)) end