Module: PaypalEvent

Defined in:
lib/paypal_event.rb,
lib/paypal_event/util.rb,
lib/paypal_event/engine.rb,
lib/paypal_event/version.rb,
app/controllers/paypal_event/webhook_controller.rb

Defined Under Namespace

Modules: Util Classes: Engine, Error, Namespace, NotificationAdapter, SignatureVerificationError, UnauthorizedError, WebhookController

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.adapterObject

Returns the value of attribute adapter.



11
12
13
# File 'lib/paypal_event.rb', line 11

def adapter
  @adapter
end

.backendObject

Returns the value of attribute backend.



11
12
13
# File 'lib/paypal_event.rb', line 11

def backend
  @backend
end

.event_filterObject

Returns the value of attribute event_filter.



11
12
13
# File 'lib/paypal_event.rb', line 11

def event_filter
  @event_filter
end

.namespaceObject

Returns the value of attribute namespace.



11
12
13
# File 'lib/paypal_event.rb', line 11

def namespace
  @namespace
end

.signing_secretsObject (readonly)

Returns the value of attribute signing_secrets.



12
13
14
# File 'lib/paypal_event.rb', line 12

def signing_secrets
  @signing_secrets
end

Class Method Details

.all(callable = Proc.new) ⇒ Object



29
30
31
# File 'lib/paypal_event.rb', line 29

def all(callable = Proc.new)
  subscribe nil, callable
end

.configure(&block) ⇒ Object Also known as: setup

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/paypal_event.rb', line 14

def configure(&block)
  raise ArgumentError, 'must provide a block' unless block_given?
  block.arity.zero? ? instance_eval(&block) : yield(self)
end

.instrument(event) ⇒ Object



20
21
22
23
# File 'lib/paypal_event.rb', line 20

def instrument(event)
  event = event_filter.call(event)
  backend.instrument namespace.call(event[:event_type]), event if event
end

.listening?(name) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/paypal_event.rb', line 33

def listening?(name)
  namespaced_name = namespace.call(name)
  backend.notifier.listening?(namespaced_name)
end

.subscribe(name, callable = Proc.new) ⇒ Object



25
26
27
# File 'lib/paypal_event.rb', line 25

def subscribe(name, callable = Proc.new)
  backend.subscribe namespace.to_regexp(name), adapter.call(callable)
end