Class: Spree::Webhooks::Subscriber

Inherits:
Base
  • Object
show all
Includes:
VendorConcern
Defined in:
app/models/spree/webhooks/subscriber.rb

Class Method Summary collapse

Class Method Details

.supported_eventsObject



39
40
41
42
43
44
45
46
# File 'app/models/spree/webhooks/subscriber.rb', line 39

def self.supported_events
  Spree::Base.descendants.
    select { |model| model.included_modules.include? Spree::Webhooks::HasWebhooks }.
    to_h do |model|
    model_name = model.name.demodulize.underscore.to_sym
    [model_name, model.supported_webhook_events]
  end
end

.with_urls_for(event) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'app/models/spree/webhooks/subscriber.rb', line 28

def self.with_urls_for(event)
  where(
    case ActiveRecord::Base.connection.adapter_name
    when 'Mysql2'
      ["('*' MEMBER OF(subscriptions) OR ? MEMBER OF(subscriptions))", event]
    when 'PostgreSQL'
      ["subscriptions @> '[\"*\"]' OR subscriptions @> ?", [event].to_json]
    end
  )
end