Class: FakeServer::Server
- Inherits:
-
Object
- Object
- FakeServer::Server
- Defined in:
- lib/fake_server/server.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#remote_api ⇒ Object
readonly
Returns the value of attribute remote_api.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(host, log_file = nil) ⇒ Server
constructor
A new instance of Server.
Constructor Details
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/fake_server/server.rb', line 12 def logger @logger end |
#remote_api ⇒ Object (readonly)
Returns the value of attribute remote_api.
12 13 14 |
# File 'lib/fake_server/server.rb', line 12 def remote_api @remote_api end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fake_server/server.rb', line 14 def call(env) url = env["REQUEST_URI"] method = env["REQUEST_METHOD"] logger.info("#{method} #{url}") if method == "GET" name = cassette_name(url) logger.info("using cassette #{name}") VCR.use_cassette(name) { remote_api.request(method, url) } else remote_api.request(method, url) end end |