Class: Ww::Double::Spy::Request
- Inherits:
-
Rack::Request
- Object
- Rack::Request
- Ww::Double::Spy::Request
- Defined in:
- lib/ww/double/spy/request.rb
Constant Summary collapse
- @@req_parsers =
[]
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(req_or_env) ⇒ Request
constructor
A new instance of Request.
- #parsed_body ⇒ Object
Constructor Details
#initialize(req_or_env) ⇒ Request
Returns a new instance of Request.
46 47 48 49 50 |
# File 'lib/ww/double/spy/request.rb', line 46 def initialize(req_or_env) env = req_or_env.is_a?(Rack::Request) ? req_or_env.env : req_or_env super(env.dup) @time = Time.now end |
Instance Attribute Details
#time ⇒ Object (readonly)
Returns the value of attribute time.
27 28 29 |
# File 'lib/ww/double/spy/request.rb', line 27 def time @time end |
Class Method Details
.regist_request_parser(pattern, &block) ⇒ Object
30 31 32 |
# File 'lib/ww/double/spy/request.rb', line 30 def self.regist_request_parser(pattern, &block) @@req_parsers << [pattern, block] end |
Instance Method Details
#parsed_body ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ww/double/spy/request.rb', line 52 def parsed_body return "" if get? return self.POST if form_data? @body ||= begin body.read ensure body.rewind end _, processor = @@req_parsers.detect{|re, ignore| re =~ media_type } processor ? processor.call(@body) : @body end |