Sha256: 64bad09aa224f62de457a975dafb873008bb31f9d44a1ebf277257877c5ecb54

Contents?: true

Size: 437 Bytes

Versions: 3

Compression:

Stored size: 437 Bytes

Contents

class Spree::Webhook
  include ActiveModel::Model
  attr_accessor :handler, :id

  WebhookNotFound = Class.new(StandardError)

  def receive(payload)
    handler.call(payload)
  end

  def self.find(id)
    id = id.to_sym # normalize incoming ids

    handler = SolidusWebhooks.config.find_webhook_handler(id) or
      raise WebhookNotFound, "Cannot find a webhook handler for #{id.inspect}"

    new(id: id, handler: handler)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_webhooks-0.1.0 app/models/spree/webhook.rb
solidus_webhooks-0.1.0.beta.1 app/models/spree/webhook.rb
solidus_webhooks-0.0.1.v0.1.0.beta.1.1 app/models/spree/webhook.rb