Class: StripeWebhooks::Callback

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Defined in:
app/models/stripe_webhooks/callback.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from ClassMethods

#event_types

Instance Method Summary collapse

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

Returns:

  • (Boolean)


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

#labelObject

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

#loggerObject



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