Sha256: 822b2d9d9ac03dcb4ea39a79dd307c425ae67d0590cf9af3ff110e54454489d8

Contents?: true

Size: 992 Bytes

Versions: 33

Compression:

Stored size: 992 Bytes

Contents

require 'action_dispatch/http/url'

module ActionDispatch::Http::URL
  
  ##
  # Enables automatic parameter propagation.
  #
  # This will only propagate within the current thread.  Child threads will not propagate.
  # This will not affect other requests in the current session.
  #
  #   ActionDispatch::Http::URL.propagated_params << :some_param
  def self.propagated_params
    @propagated_params ||= []
  end
  
  def self.path_for(options)
    
    if (request = Incline::current_request)
      propagated_params.each do |k|
        if request.params.key? k
          options[:params] ||= {}
          options[:params][k] = request.params[k]
        end
      end
    end
    
    path  = options[:script_name].to_s.chomp("/")
    path << options[:path] if options.key?(:path)

    add_trailing_slash(path) if options[:trailing_slash]
    add_params(path, options[:params]) if options.key?(:params)
    add_anchor(path, options[:anchor]) if options.key?(:anchor)

    path
  end

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
incline-0.3.13 lib/incline/extensions/param_propagation.rb
incline-0.3.12 lib/incline/extensions/param_propagation.rb
incline-0.3.11 lib/incline/extensions/param_propagation.rb
incline-0.3.10 lib/incline/extensions/param_propagation.rb
incline-0.3.9 lib/incline/extensions/param_propagation.rb
incline-0.3.8 lib/incline/extensions/param_propagation.rb
incline-0.3.7 lib/incline/extensions/param_propagation.rb
incline-0.3.6 lib/incline/extensions/param_propagation.rb
incline-0.3.5 lib/incline/extensions/param_propagation.rb
incline-0.3.4 lib/incline/extensions/param_propagation.rb
incline-0.3.3 lib/incline/extensions/param_propagation.rb
incline-0.3.2 lib/incline/extensions/param_propagation.rb
incline-0.3.1 lib/incline/extensions/param_propagation.rb
incline-0.3.0 lib/incline/extensions/param_propagation.rb
incline-0.2.36 lib/incline/extensions/param_propagation.rb
incline-0.2.35 lib/incline/extensions/param_propagation.rb
incline-0.2.34 lib/incline/extensions/param_propagation.rb
incline-0.2.28 lib/incline/extensions/param_propagation.rb
incline-0.2.27 lib/incline/extensions/param_propagation.rb
incline-0.2.26 lib/incline/extensions/param_propagation.rb