Class: Spree::Webhook

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
app/models/spree/webhook.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#handlerObject

Returns the value of attribute handler.



5
6
7
# File 'app/models/spree/webhook.rb', line 5

def handler
  @handler
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'app/models/spree/webhook.rb', line 5

def id
  @id
end

Class Method Details

.find(id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'app/models/spree/webhook.rb', line 15

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

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

  new(id: id, handler: handler)
end

Instance Method Details

#receive(payload, user) ⇒ Object



7
8
9
10
11
12
13
# File 'app/models/spree/webhook.rb', line 7

def receive(payload, user)
  if handler_arity == 1
    handler.call(payload)
  else
    handler.call(payload, user)
  end
end