Module: Axn::Webhooks::Parsers

Defined in:
lib/axn/webhooks/inbound/parsers.rb

Overview

Builds the callable that turns a Request into the parsed event a dispatcher routes on.

Class Method Summary collapse

Class Method Details

.build(option) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/axn/webhooks/inbound/parsers.rb', line 11

def build(option)
  case option
  when nil, :json then ->(request) { JSON.parse(request.raw_body) }
  when Proc       then option
  else raise Axn::Webhooks::Error, "unknown parse option #{option.inspect} (use :json or a proc)"
  end
end