Sha256: 363d44624071de23ae36c7a017c17b0444214428132019e9b7ec85d4a37fdf6a

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 Bytes

Contents

module Wovnrb
  def self.middleware_inserted?(app, middleware)
    app.middleware.send(:operations).each do |_, middlewares, _|
      return true if middlewares&.include?(middleware)
    end

    false
  end

  class Railtie < Rails::Railtie
    initializer 'wovnrb.configure_rails_initialization' do |app|
      unless Wovnrb.middleware_inserted?(app, Wovnrb::Interceptor)
        if defined?(Rack::Deflater) && Wovnrb.middleware_inserted?(app, Rack::Deflater)
          app.middleware.insert_after(Rack::Deflater, Wovnrb::Interceptor)
        else
          app.middleware.insert_before(0, Wovnrb::Interceptor)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wovnrb-2.6.0 lib/wovnrb/railtie.rb
wovnrb-2.5.1 lib/wovnrb/railtie.rb