Class: HttpDouble::RequestLogger::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/http_double/request_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Request

Returns a new instance of Request.



47
48
49
# File 'lib/http_double/request_logger.rb', line 47

def initialize(env)
  @env = env
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



69
70
71
# File 'lib/http_double/request_logger.rb', line 69

def method_missing(sym, *args, &block)
  parsed_input.__send__ sym, *args, &block
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



45
46
47
# File 'lib/http_double/request_logger.rb', line 45

def env
  @env
end

Instance Method Details

#[](field, index = nil) ⇒ Object



63
64
65
66
67
# File 'lib/http_double/request_logger.rb', line 63

def [](field, index = nil)
  result = parsed_input[field]
  result = result[index] if result and index
  result
end

#bodyObject



51
52
53
# File 'lib/http_double/request_logger.rb', line 51

def body
  @body ||= rack_input.rewind && rack_input.read
end

#pathObject



59
60
61
# File 'lib/http_double/request_logger.rb', line 59

def path
  env['REQUEST_PATH']
end

#respond_to_missing?(sym) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/http_double/request_logger.rb', line 73

def respond_to_missing?(sym)
  parsed_input.respond_to? sym
end

#verbObject



55
56
57
# File 'lib/http_double/request_logger.rb', line 55

def verb
  env['REQUEST_METHOD'].downcase.to_sym
end