Sha256: 43bfaf7559265560b7e99ab2a6d6c58778f820fc074e9689079a36b1118390ed

Contents?: true

Size: 593 Bytes

Versions: 3

Compression:

Stored size: 593 Bytes

Contents

module ParamsKeeper
  class UrlFor
    def initialize(caller, controller, url_options)
      @caller = caller
      @controller = controller
      @url_options = url_options
    end

    def call
      return if @controller.class.keep_params_configs.blank?

      resolver = ParamsKeeper::Resolver.new(@controller, @url_options)
      params = resolver.call
      return if params.blank?

      base_url_for(resolver.url_options_hash.reverse_merge(params))
    end

    private

    def base_url_for(url_options)
      @caller.method(:url_for).super_method.call(url_options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
params_keeper_rails-1.2.2 lib/params_keeper/url_for.rb
params_keeper_rails-1.2.1 lib/params_keeper/url_for.rb
params_keeper_rails-1.2.0 lib/params_keeper/url_for.rb