Class: WebhookInbox::Configuration
- Inherits:
-
Object
- Object
- WebhookInbox::Configuration
- Defined in:
- lib/webhook_inbox/configuration.rb
Instance Attribute Summary collapse
-
#dashboard_auth ⇒ Object
Returns the value of attribute dashboard_auth.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
Instance Method Summary collapse
-
#handlers_for(provider, event_type) ⇒ Object
Returns all matching handler blocks for [provider, event_type].
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#on(provider, event_type, &block) ⇒ Object
Register a handler block for a given provider + event type.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 |
# File 'lib/webhook_inbox/configuration.rb', line 7 def initialize @queue_name = "webhooks" @dashboard_auth = nil @handlers = {} end |
Instance Attribute Details
#dashboard_auth ⇒ Object
Returns the value of attribute dashboard_auth.
5 6 7 |
# File 'lib/webhook_inbox/configuration.rb', line 5 def dashboard_auth @dashboard_auth end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
5 6 7 |
# File 'lib/webhook_inbox/configuration.rb', line 5 def queue_name @queue_name end |
Instance Method Details
#handlers_for(provider, event_type) ⇒ Object
Returns all matching handler blocks for [provider, event_type]. Includes exact matches and wildcard “*” handlers for the provider.
28 29 30 31 32 |
# File 'lib/webhook_inbox/configuration.rb', line 28 def handlers_for(provider, event_type) exact = @handlers[handler_key(provider, event_type)] || [] wildcard = @handlers[handler_key(provider, "*")] || [] exact + wildcard end |
#on(provider, event_type, &block) ⇒ Object
Register a handler block for a given provider + event type. Use “*” as event_type to match any event from that provider.
config.on(:stripe, "customer.subscription.created") { |event| ... }
config.on(:stripe, "*") { |event| ... }
18 19 20 21 22 23 24 |
# File 'lib/webhook_inbox/configuration.rb', line 18 def on(provider, event_type, &block) raise ArgumentError, "Handler block required" unless block key = handler_key(provider, event_type) @handlers[key] ||= [] @handlers[key] << block end |