Class: Eventish::ActiveJobEvent
- Inherits:
-
ActiveJob::Base
- Object
- ActiveJob::Base
- Eventish::ActiveJobEvent
show all
- Extended by:
- EventApi
- Defined in:
- lib/eventish/active_job_event.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from EventApi
<=>, after_event, before_event, event_name, priority, subscribe, subscribe_all, unsubscribe
Class Method Details
.trigger(target, args, &_block) ⇒ Object
23
24
25
26
27
|
# File 'lib/eventish/active_job_event.rb', line 23
def trigger(target, args, &_block)
return unless new.callable?(target)
perform_later(target, args)
end
|
Instance Method Details
#call(_target, _args, &_block) ⇒ Object
5
6
7
|
# File 'lib/eventish/active_job_event.rb', line 5
def call(_target, _args, &_block)
raise NotImplementedError
end
|
#callable?(_target) ⇒ Boolean
9
10
11
|
# File 'lib/eventish/active_job_event.rb', line 9
def callable?(_target)
true
end
|
13
14
15
16
17
18
|
# File 'lib/eventish/active_job_event.rb', line 13
def perform(target, args)
self.class.before_event.each { |plugin| plugin.call(target, args, event: self, hook: :before) }
call(target, args)
self.class.after_event.each { |plugin| plugin.call(target, args, event: self, hook: :after) }
self
end
|