Class: Waylon::WebhookRegistry
- Inherits:
-
Object
- Object
- Waylon::WebhookRegistry
- Includes:
- Singleton
- Defined in:
- lib/waylon/webhook_registry.rb
Overview
Registry of Webhook subclasses known to Waylon
Instance Attribute Summary collapse
-
#webhooks ⇒ Object
readonly
Returns the value of attribute webhooks.
Class Method Summary collapse
-
.register(name, class_name) ⇒ Class
A convenience wrapper around the singleton instance #register method.
Instance Method Summary collapse
-
#register(name, class_name) ⇒ Class
Add the provided Webhook class to the registry under ‘name`.
-
#to_hash ⇒ Hash
Provides a Hash version of this registry.
Instance Attribute Details
#webhooks ⇒ Object (readonly)
Returns the value of attribute webhooks.
8 9 10 |
# File 'lib/waylon/webhook_registry.rb', line 8 def webhooks @webhooks end |
Class Method Details
.register(name, class_name) ⇒ Class
A convenience wrapper around the singleton instance #register method
13 14 15 |
# File 'lib/waylon/webhook_registry.rb', line 13 def self.register(name, class_name) instance.register(name, class_name) end |
Instance Method Details
#register(name, class_name) ⇒ Class
Add the provided Webhook class to the registry under ‘name`
21 22 23 24 |
# File 'lib/waylon/webhook_registry.rb', line 21 def register(name, class_name) @webhooks ||= {} @webhooks[name.to_s] = class_name end |
#to_hash ⇒ Hash
Provides a Hash version of this registry
28 29 30 |
# File 'lib/waylon/webhook_registry.rb', line 28 def to_hash (@webhooks || {}).transform_keys { |k| "/hooks/#{k}" } end |