Class: MockServer::Record
- Inherits:
-
Object
- Object
- MockServer::Record
- Includes:
- Utils
- Defined in:
- lib/mock_server/record.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(app, options = {}) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 |
# File 'lib/mock_server/record.rb', line 7 def initialize(app, = {}) @options = @app = app $mock_server_options ||= end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mock_server/record.rb', line 13 def call(env) return @app.call(env) unless $mock_server_options and $mock_server_options[:routes] and lazy_match $mock_server_options[:routes], env["PATH_INFO"] @options.merge!($mock_server_options) @request = Rack::Request.new(env) @data = load_data @app.call(env).tap do |response| record_response(response) response end end |