class Chewy::Railtie::RequestStrategy

Public Class Methods

new(app) click to toggle source
# File lib/chewy/railtie.rb, line 8
def initialize(app)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/chewy/railtie.rb, line 12
def call(env)
  # For Rails applications in `api_only` mode, the `assets` config isn't present
  if Rails.application.config.respond_to?(:assets) && env['PATH_INFO'].start_with?(Rails.application.config.assets.prefix)
    @app.call(env)
  else
    if Chewy.logger && @request_strategy != Chewy.request_strategy
      Chewy.logger.info("Chewy request strategy is `#{Chewy.request_strategy}`")
    end
    @request_strategy = Chewy.request_strategy
    Chewy.strategy(Chewy.request_strategy) { @app.call(env) }
  end
end