Sha256: a99cd91b3010e055c322bd6a0254ffb22b68fe4e58b11ab9d2c4a92db1097775

Contents?: true

Size: 652 Bytes

Versions: 5

Compression:

Stored size: 652 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

5 entries across 5 versions & 1 rubygems

Version Path
wovnrb-2.2.4 lib/wovnrb/railtie.rb
wovnrb-2.2.3 lib/wovnrb/railtie.rb
wovnrb-2.2.2 lib/wovnrb/railtie.rb
wovnrb-2.2.1 lib/wovnrb/railtie.rb
wovnrb-2.2.0 lib/wovnrb/railtie.rb