Sha256: eb06d979bf38da5f9d38c58f84a6a6f2dec0214118671057db8f74f23f3f44f2

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

module ActionDispatchJourneyRouterWithFiltering
  def find_routes(env)
    path = env.is_a?(Hash) ? env['PATH_INFO'] : env.path_info
    filter_parameters = {}
    original_path = path.dup

    @routes.filters.run(:around_recognize, path, env) do
      filter_parameters
    end

    super(env).map do | route|
      env.parameters.merge(filter_parameters)
      [ route ]
    end.tap do |route|
      # restore the original path
      if env.is_a?(Hash)
        env['PATH_INFO'] = original_path
      else
        env.path_info = original_path
      end
    end
  end
end

ActionDispatch::Journey::Router.send(:prepend, ActionDispatchJourneyRouterWithFiltering)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
routing-filter-codeur-0.7.1.1 lib/routing_filter/adapters/routers/journey.rb
routing-filter-codeur-0.7.1 lib/routing_filter/adapters/routers/journey.rb