Class: OpenapiContracts::PayloadParser
- Inherits:
-
Object
- Object
- OpenapiContracts::PayloadParser
- Includes:
- Singleton
- Defined in:
- lib/openapi_contracts/payload_parser.rb
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
-
#initialize ⇒ PayloadParser
constructor
A new instance of PayloadParser.
- #parse(media_type, payload) ⇒ Object
- #register(matcher, parser) ⇒ Object
Constructor Details
#initialize ⇒ PayloadParser
Returns a new instance of PayloadParser.
21 22 23 |
# File 'lib/openapi_contracts/payload_parser.rb', line 21 def initialize @parsers = [] end |
Instance Method Details
#parse(media_type, payload) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/openapi_contracts/payload_parser.rb', line 25 def parse(media_type, payload) parser = @parsers.find { |e| e.match?(media_type) } raise ArgumentError, "#{media_type.inspect} is not supported yet" unless parser parser.call(payload) end |