Class: ActiveWebhook::Queueing::BaseAdapter
- Defined in:
- lib/active_webhook/queueing/base_adapter.rb
Direct Known Subclasses
ActiveJobAdapter, DelayedJobAdapter, SidekiqAdapter, SyncronousAdapter
Class Method Summary collapse
- .build_hook(subscription, **context) ⇒ Object
- .fulfill_subscription(subscription:, hook: nil, **context) ⇒ Object
Instance Method Summary collapse
-
#call ⇒ Object
returns count of jobs enqueued.
- #format_first ⇒ Object
- #fulfill_topic ⇒ Object
Methods inherited from Adapter
attribute, attributes, #attributes, call, component_configuration, #component_configuration, configuration, #configuration, #initialize
Constructor Details
This class inherits a constructor from ActiveWebhook::Adapter
Class Method Details
.build_hook(subscription, **context) ⇒ Object
20 21 22 |
# File 'lib/active_webhook/queueing/base_adapter.rb', line 20 def self.build_hook(subscription, **context) ActiveWebhook.formatting_adapter.call(subscription: subscription, **context) end |
.fulfill_subscription(subscription:, hook: nil, **context) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/active_webhook/queueing/base_adapter.rb', line 24 def self.fulfill_subscription(subscription:, hook: nil, **context) ActiveWebhook.delivery_adapter.call( subscription: subscription, hook: hook || build_hook(subscription, **context), **context ) if ActiveWebhook.enabled? true end |
Instance Method Details
#call ⇒ Object
returns count of jobs enqueued
13 14 15 16 17 18 |
# File 'lib/active_webhook/queueing/base_adapter.rb', line 13 def call return fulfill_topic if format_first promise_topic 1 end |
#format_first ⇒ Object
8 9 10 |
# File 'lib/active_webhook/queueing/base_adapter.rb', line 8 def format_first @format_first.nil? ? component_configuration.format_first : @format_first end |
#fulfill_topic ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/active_webhook/queueing/base_adapter.rb', line 33 def fulfill_topic subscriptions.each do |subscription| hook = format_first ? self.class.build_hook(subscription, **context) : nil byebug if context.key?("key") promise_subscription subscription: subscription, hook: hook end subscriptions.count end |