Class: Mimic::FakeHost::RequestEcho
- Inherits:
-
Object
- Object
- Mimic::FakeHost::RequestEcho
- Defined in:
- lib/mimic/fake_host.rb
Instance Method Summary collapse
-
#initialize(request) ⇒ RequestEcho
constructor
A new instance of RequestEcho.
- #response_as(format) ⇒ Object
- #to_hash ⇒ Object
- #to_s(format) ⇒ Object
Constructor Details
#initialize(request) ⇒ RequestEcho
Returns a new instance of RequestEcho.
106 107 108 |
# File 'lib/mimic/fake_host.rb', line 106 def initialize(request) @request = request end |
Instance Method Details
#response_as(format) ⇒ Object
110 111 112 113 114 115 116 117 118 |
# File 'lib/mimic/fake_host.rb', line 110 def response_as(format) content_type = case format when :json, :plist "application/#{format.to_s.downcase}" else "text/plain" end [200, {"Content-Type" => content_type}, to_s(format)] end |
#to_hash ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/mimic/fake_host.rb', line 131 def to_hash {"echo" => { "params" => @request.params, "env" => env_without_rack_and_async_env, "body" => @request.body.read }} end |
#to_s(format) ⇒ Object
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/mimic/fake_host.rb', line 120 def to_s(format) case format when :json to_hash.to_json when :plist to_hash.to_plist when :text to_hash.inspect end end |