Module: Eventish
- Defined in:
- lib/eventish/version.rb,
lib/eventish.rb,
lib/eventish/event_api.rb,
lib/eventish/simple_event.rb,
lib/eventish/plugins/logger.rb,
lib/eventish/adapters/wisper.rb,
lib/eventish/active_job_event.rb,
lib/eventish/plugins/rails_logger.rb,
lib/eventish/active_record/callback.rb,
lib/eventish/adapters/active_support.rb
Overview
Defined Under Namespace
Modules: ActiveRecord, Adapters, EventApi, Plugins
Classes: ActiveJobEvent, SimpleEvent
Constant Summary
collapse
- OPTIONS =
i[adapter after_event before_event].freeze
- AdapterError =
Class.new(StandardError)
- VERSION =
'0.5.1'
Class Method Summary
collapse
Class Method Details
.adapter ⇒ Object
13
14
15
|
# File 'lib/eventish.rb', line 13
def adapter
config.adapter
end
|
.config ⇒ Object
17
18
19
|
# File 'lib/eventish.rb', line 17
def config
@options ||= Struct.new(*OPTIONS).new
end
|
.descendants(klass) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/eventish.rb', line 22
def descendants(klass)
descendants = []
ObjectSpace.each_object(klass.singleton_class) do |k|
next if k.singleton_class?
descendants.unshift k unless k == self
end
descendants
end
|
.publish(event_name, target = nil, block: nil) ⇒ Object
32
33
34
|
# File 'lib/eventish.rb', line 32
def publish(event_name, target = nil, block: nil)
config.adapter&.publish(event_name, target, block: block)
end
|
.setup {|@options| ... } ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/eventish.rb', line 36
def setup
@options ||= Struct.new(*OPTIONS).new
yield(@options) if block_given?
raise AdapterError, 'Please specify an event adapter' unless @options.adapter
@options
end
|
.subscribers ⇒ Object
44
45
46
|
# File 'lib/eventish.rb', line 44
def subscribers
@subscribers ||= {}
end
|