Module: Metova::Webhookable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/metova/webhooks/models/webhookable.rb
Instance Method Summary collapse
- #create_hook ⇒ Object
- #destroy_hook ⇒ Object
- #hook_name ⇒ Object
- #namespace ⇒ Object
- #update_hook ⇒ Object
- #webhook_event(event) ⇒ Object
- #webhook_serialize ⇒ Object
Instance Method Details
#create_hook ⇒ Object
22 23 24 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 22 def create_hook Metova::WebhookJob.perform_later webhook_event('create'), self.webhook_serialize end |
#destroy_hook ⇒ Object
30 31 32 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 30 def destroy_hook Metova::WebhookJob.perform_later webhook_event('destroy'), self.webhook_serialize end |
#hook_name ⇒ Object
14 15 16 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 14 def hook_name self.class.to_s.underscore end |
#namespace ⇒ Object
10 11 12 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 10 def namespace '' end |
#update_hook ⇒ Object
26 27 28 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 26 def update_hook Metova::WebhookJob.perform_later webhook_event('update'), self.webhook_serialize end |
#webhook_event(event) ⇒ Object
18 19 20 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 18 def webhook_event(event) [namespace, hook_name, event].reject(&:empty?).join(':') end |
#webhook_serialize ⇒ Object
34 35 36 |
# File 'lib/metova/webhooks/models/webhookable.rb', line 34 def webhook_serialize self.to_json end |