Class: StripeWebhooks::Callback
- Inherits:
-
Object
- Object
- StripeWebhooks::Callback
- Extended by:
- ClassMethods
- Defined in:
- app/models/stripe_webhooks/callback.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary
Attributes included from ClassMethods
Instance Method Summary collapse
-
#handles?(event_type) ⇒ Boolean
Return true if the Callback handles this type of event.
-
#label ⇒ Object
Return the label for the callback.
- #logger ⇒ Object
-
#run_once(event) ⇒ Object
Run the callback only if we have not run it once before.
Methods included from ClassMethods
handles_events, inherited, run_callbacks_for
Instance Method Details
#handles?(event_type) ⇒ Boolean
Return true if the Callback handles this type of event
65 66 67 |
# File 'app/models/stripe_webhooks/callback.rb', line 65 def handles?(event_type) return self.class.event_types.include?(event_type) end |
#label ⇒ Object
Return the label for the callback. Label is based on the class name.
50 51 52 |
# File 'app/models/stripe_webhooks/callback.rb', line 50 def label return self.class.to_s.underscore.gsub('_callback', '') end |
#logger ⇒ Object
44 45 46 |
# File 'app/models/stripe_webhooks/callback.rb', line 44 def logger return Rails.logger end |
#run_once(event) ⇒ Object
Run the callback only if we have not run it once before
56 57 58 59 60 61 |
# File 'app/models/stripe_webhooks/callback.rb', line 56 def run_once(event) unless StripeWebhooks::PerformedCallback.exists?(stripe_event_id: event.id, label: label) run(event) StripeWebhooks::PerformedCallback.create(stripe_event_id: event.id, label: label) end end |