Class: Zooplankton::Resolver

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(routes) ⇒ Resolver

Returns a new instance of Resolver.



9
10
11
# File 'lib/zooplankton/resolver.rb', line 9

def initialize(routes)
  @routes = routes
end

Class Method Details

.instanceObject



5
6
7
# File 'lib/zooplankton/resolver.rb', line 5

def self.instance
  new(Rails.application.routes)
end

Instance Method Details

#generate(helper_method, helper_name, params = {}) ⇒ Object



17
18
19
20
# File 'lib/zooplankton/resolver.rb', line 17

def generate(helper_method, helper_name, params = {})
  route = named_routes[helper_name]
  routes.url_helpers.public_send(helper_method, *tokenized_params_for(route, params))
end

#has_route?(name) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/zooplankton/resolver.rb', line 13

def has_route?(name)
  names.include?(name)
end