Class: Spree::WebhookEndpoint
- Inherits:
-
Object
- Object
- Spree::WebhookEndpoint
- Includes:
- SingleStoreResource
- Defined in:
- app/models/spree/webhook_endpoint.rb
Instance Method Summary collapse
-
#subscribed_events ⇒ Array<String>
Returns all events this endpoint is subscribed to.
-
#subscribed_to?(event_name) ⇒ Boolean
Check if this endpoint is subscribed to a specific event.
Instance Method Details
#subscribed_events ⇒ Array<String>
Returns all events this endpoint is subscribed to
41 42 43 44 45 |
# File 'app/models/spree/webhook_endpoint.rb', line 41 def subscribed_events return ['*'] if subscriptions.blank? subscriptions end |
#subscribed_to?(event_name) ⇒ Boolean
Check if this endpoint is subscribed to a specific event
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/spree/webhook_endpoint.rb', line 25 def subscribed_to?(event_name) return true if subscriptions.blank? || subscriptions.include?('*') subscriptions.any? do |subscription| if subscription.include?('*') pattern = Regexp.escape(subscription).gsub('\*', '.*') event_name.match?(Regexp.new("^#{pattern}$")) else subscription == event_name end end end |