Class: Holoserve::Request::Decomposer

Inherits:
Object
  • Object
show all
Defined in:
lib/holoserve/request/decomposer.rb

Constant Summary collapse

ONLY_HEADERS =
[
  "SERVER_SOFTWARE",
  "SERVER_NAME",
  "SERVER_PORT",
  "REMOTE_ADDR",
  "SCRIPT_NAME",
  "CONTENT_TYPE"
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(request, parameters) ⇒ Decomposer

Returns a new instance of Decomposer.



13
14
15
# File 'lib/holoserve/request/decomposer.rb', line 13

def initialize(request, parameters)
  @request, @parameters = request, parameters
end

Instance Method Details

#hashObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/holoserve/request/decomposer.rb', line 17

def hash
  hash = {
    :method => @request["REQUEST_METHOD"],
    :path => @request["REQUEST_PATH"]
  }
  hash[:headers] = headers unless headers.empty?
  hash[:body] = body unless body.nil?
  hash[:parameters] = parameters unless parameters.empty?
  hash[:oauth] = oauth unless oauth.empty?
  hash[:json] = json unless json.empty?
  hash
end