Class: ApiFixtures::Middleware
- Inherits:
-
Object
- Object
- ApiFixtures::Middleware
- Defined in:
- lib/api_fixtures/middleware.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
3 4 5 |
# File 'lib/api_fixtures/middleware.rb', line 3 def initialize(app) @app = app end |
Class Method Details
.must_be_in_stack! ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/api_fixtures/middleware.rb', line 12 def self.must_be_in_stack! if defined?(Rails::Application) unless Rails.application.middleware.include?(self) raise "ApiFixtures::Middleware needs to be in the middleware stack" end true else false end end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 |
# File 'lib/api_fixtures/middleware.rb', line 7 def call(env) request = Rack::Request.new(env) ApiFixtures::Fixtures.lookup(request.request_method, request.path) || @app.call(env) end |