Class: ParamsKeeper::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/params_keeper/resolver.rb

Instance Method Summary collapse

Constructor Details

#initialize(controller, url_options) ⇒ Resolver

Returns a new instance of Resolver.



5
6
7
8
9
# File 'lib/params_keeper/resolver.rb', line 5

def initialize(controller, url_options)
  @controller = controller
  @url_options = url_options
  @cache = {}
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
# File 'lib/params_keeper/resolver.rb', line 11

def call
  return {} if configs.blank? || skip_url_options?

  configs.each_with_object({}) do |config, params|
    if target_config?(config)
      params.merge!(extract_params(config))
    end
  end
end

#url_options_hashObject



21
22
23
24
25
26
27
# File 'lib/params_keeper/resolver.rb', line 21

def url_options_hash
  if @url_options.is_a?(Hash)
    @url_options
  else
    recognize_path(base_url_for(@url_options))
  end
end