Class: Hooksmith::Config::Provider
- Inherits:
-
Object
- Object
- Hooksmith::Config::Provider
- Defined in:
- lib/hooksmith/config/provider.rb
Overview
Provider is used internally by the DSL to collect processor registrations, optional verifier configuration, and idempotency settings.
Uses string keys internally to prevent Symbol DoS attacks when processing untrusted webhook input.
Instance Attribute Summary collapse
-
#entries ⇒ Array<Hash>
readonly
List of entries registered.
-
#idempotency_key ⇒ Proc?
The idempotency key extractor for this provider.
-
#provider ⇒ String
readonly
The provider name.
-
#verifier ⇒ Hooksmith::Verifiers::Base?
The verifier for this provider.
Instance Method Summary collapse
-
#initialize(provider) ⇒ Provider
constructor
A new instance of Provider.
-
#register(event, processor_class_name) ⇒ Object
Registers a processor for a specific event.
Constructor Details
#initialize(provider) ⇒ Provider
Returns a new instance of Provider.
31 32 33 34 35 36 |
# File 'lib/hooksmith/config/provider.rb', line 31 def initialize(provider) @provider = provider.to_s @entries = [] @verifier = nil @idempotency_key = nil end |
Instance Attribute Details
#entries ⇒ Array<Hash> (readonly)
Returns list of entries registered.
14 15 16 |
# File 'lib/hooksmith/config/provider.rb', line 14 def entries @entries end |
#idempotency_key ⇒ Proc?
Returns the idempotency key extractor for this provider.
29 30 31 |
# File 'lib/hooksmith/config/provider.rb', line 29 def idempotency_key @idempotency_key end |
#provider ⇒ String (readonly)
Returns the provider name.
12 13 14 |
# File 'lib/hooksmith/config/provider.rb', line 12 def provider @provider end |
#verifier ⇒ Hooksmith::Verifiers::Base?
Returns the verifier for this provider.
23 24 25 |
# File 'lib/hooksmith/config/provider.rb', line 23 def verifier @verifier end |
Instance Method Details
#register(event, processor_class_name) ⇒ Object
Registers a processor for a specific event.
42 43 44 |
# File 'lib/hooksmith/config/provider.rb', line 42 def register(event, processor_class_name) entries << { event: event.to_s, processor: processor_class_name } end |