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, run_callbacks_for
Instance Method Details
#handles?(event_type) ⇒ Boolean
Return true if the Callback handles this type of event
61 62 63 |
# File 'app/models/stripe_webhooks/callback.rb', line 61 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.
46 47 48 |
# File 'app/models/stripe_webhooks/callback.rb', line 46 def label return self.class.to_s.underscore.gsub('_callback', '') end |
#logger ⇒ Object
40 41 42 |
# File 'app/models/stripe_webhooks/callback.rb', line 40 def logger return Rails.logger end |
#run_once(event) ⇒ Object
Run the callback only if we have not run it once before
52 53 54 55 56 57 |
# File 'app/models/stripe_webhooks/callback.rb', line 52 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 |