Module: RecurlyEvent
- Defined in:
- lib/recurly_event.rb,
lib/recurly_event/engine.rb,
lib/recurly_event/parser.rb,
lib/recurly_event/version.rb,
lib/recurly_event/namespace.rb,
app/controllers/recurly_event/webhook_controller.rb
Defined Under Namespace
Classes: Engine, Namespace, Parser, WebhookController
Constant Summary
collapse
- NAMESPACE =
"recurly".freeze
- VERSION =
"1.0.0"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.namespace ⇒ Object
Returns the value of attribute namespace.
11
12
13
|
# File 'lib/recurly_event.rb', line 11
def namespace
@namespace
end
|
.notifications ⇒ Object
Returns the value of attribute notifications.
11
12
13
|
# File 'lib/recurly_event.rb', line 11
def notifications
@notifications
end
|
.parser ⇒ Object
Returns the value of attribute parser.
11
12
13
|
# File 'lib/recurly_event.rb', line 11
def parser
@parser
end
|
Class Method Details
.all(callable = Proc.new {}) ⇒ Object
18
19
20
|
# File 'lib/recurly_event.rb', line 18
def all(callable=Proc.new {})
subscribe nil, callable
end
|
13
14
15
16
|
# File 'lib/recurly_event.rb', line 13
def configure(&block)
raise ArgumentError, "missing block" unless block_given?
yield self
end
|
.process_request(request) ⇒ Object
22
23
24
25
|
# File 'lib/recurly_event.rb', line 22
def process_request(request)
parsed_request = parser.parse(request)
publish(parsed_request.event_name, parsed_request.payload)
end
|
.publish(event_name, payload) ⇒ Object
27
28
29
|
# File 'lib/recurly_event.rb', line 27
def publish(event_name, payload)
notifications.instrument(namespace.parse_with_namespace(event_name), payload)
end
|
.subscribe(event_name, callable = Proc.new {}) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/recurly_event.rb', line 31
def subscribe(event_name, callable=Proc.new {})
notifications.subscribe namespace.regexp_wrap(event_name) do |*args|
recurly_object = parser.from_payload(args.last)
callable.call(recurly_object)
end
end
|