Module: Shaf::Parser

Defined in:
lib/shaf/parser.rb,
lib/shaf/parser/base.rb,
lib/shaf/parser/json.rb,
lib/shaf/parser/form_data.rb

Defined Under Namespace

Classes: Base, Error, FormData, Json

Constant Summary collapse

INPUT_BODY =
'shaf.input_body'

Class Method Summary collapse

Class Method Details

.for(request) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/shaf/parser.rb', line 24

def for(request)
  clazz = parser_for(request)
  return unless clazz

  body = input(request)
  clazz.new(request: request, body: body)
end

.input?(request) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/shaf/parser.rb', line 20

def input?(request)
  !!input(request)
end

.register(parser) ⇒ Object



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

def register(parser)
  parsers << parser
end

.unregister(parser) ⇒ Object



16
17
18
# File 'lib/shaf/parser.rb', line 16

def unregister(parser)
  parsers.delete(parser)
end