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.
-
#run_once(event) ⇒ Object
Run the callback only if we have not run it once before.
Methods included from ClassMethods
handles_events, run_callbacks_for
Instance Method Details
#handles?(event_type) ⇒ Boolean
Return true if the Callback handles this type of event
57 58 59 |
# File 'app/models/stripe_webhooks/callback.rb', line 57 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.
42 43 44 |
# File 'app/models/stripe_webhooks/callback.rb', line 42 def label return self.class.to_s.underscore.gsub('_callback', '') end |
#run_once(event) ⇒ Object
Run the callback only if we have not run it once before
48 49 50 51 52 53 |
# File 'app/models/stripe_webhooks/callback.rb', line 48 def run_once(event) if !StripeWebhooks::PerformedCallback.exists?(:stripe_event_id => event.id, :label => label) run(event) StripeWebhooks::PerformedCallback.create(:stripe_event_id => event.id, :label => label) end end |