class Rack::BodyDeserializer

Constants

INPUT_KEY
RACK_KEY
TYPE_KEY
VERSION

Attributes

mapping[R]

Public Class Methods

new(stack, mapping) click to toggle source
# File lib/rack/body_deserializer.rb, line 11
def initialize(stack, mapping)
  @stack = stack
  @mapping = mapping
end

Public Instance Methods

call(previous_state) click to toggle source
# File lib/rack/body_deserializer.rb, line 16
def call(previous_state)
  @state = previous_state
  if deserializable?
    state[RACK_KEY] = deserializer.load(input)
  end
  stack.call(state)
end

Private Instance Methods

body() click to toggle source
# File lib/rack/body_deserializer.rb, line 60
        def body
  @body
end
content_type() click to toggle source
# File lib/rack/body_deserializer.rb, line 32
        def content_type
  state[TYPE_KEY]
end
deserializable?() click to toggle source
# File lib/rack/body_deserializer.rb, line 24
        def deserializable?
  content_type && deserializer && stringable?
end
deserializer() click to toggle source
# File lib/rack/body_deserializer.rb, line 36
        def deserializer
  mapping[content_type]
end
headers() click to toggle source
# File lib/rack/body_deserializer.rb, line 52
        def headers
  @headers
end
input() click to toggle source
# File lib/rack/body_deserializer.rb, line 28
        def input
  state[INPUT_KEY].string
end
stack() click to toggle source
# File lib/rack/body_deserializer.rb, line 44
        def stack
  @stack
end
state() click to toggle source
# File lib/rack/body_deserializer.rb, line 48
        def state
  @state
end
status() click to toggle source
# File lib/rack/body_deserializer.rb, line 56
        def status
  @status
end
stringable?() click to toggle source
# File lib/rack/body_deserializer.rb, line 40
        def stringable?
  state[INPUT_KEY].respond_to?(:string)
end