Module: MuchRailsPubSub
- Includes:
- MuchRails::Config
- Defined in:
- lib/much-rails-pub-sub.rb,
lib/much-rails-pub-sub/version.rb
Defined Under Namespace
Modules: PublishJobBehaviors
Classes: ActiveJobPublisher, Config, Publisher, Subscription, TestPublisher
Constant Summary
collapse
- VERSION =
"0.1.0"
Class Method Summary
collapse
Class Method Details
.load_subscriptions(subscriptions_file_path) ⇒ Object
44
45
46
47
48
|
# File 'lib/much-rails-pub-sub.rb', line 44
def self.load_subscriptions(subscriptions_file_path)
config.constantize_publish_job_class
Kernel.load(subscriptions_file_path)
end
|
.publish(event_name, **event_params) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/much-rails-pub-sub.rb', line 14
def self.publish(event_name, **event_params)
config
.publisher_class
.call(event_name, event_params: event_params)
.tap do |event|
published_events << event
config.logger.info(
"[MuchRailsPubSub] Published #{event.name.inspect}:\n"\
" ID: #{event.id.inspect}\n"\
" PARAMS: #{event.params.inspect}",
)
end
end
|
.published_events ⇒ Object
36
37
38
|
# File 'lib/much-rails-pub-sub.rb', line 36
def self.published_events
config.published_events
end
|
.setup_test_publishing ⇒ Object
.subscribe(event_name, job:) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/much-rails-pub-sub.rb', line 28
def self.subscribe(event_name, job:)
subscriptions <<
MuchRailsPubSub::Subscription.new(
event_name,
job_class: config.constantize_job(job, type: :subscription),
)
end
|
.subscriptions ⇒ Object
40
41
42
|
# File 'lib/much-rails-pub-sub.rb', line 40
def self.subscriptions
config.subscriptions
end
|