Class: Zooplankton::Resolver
- Inherits:
-
Object
- Object
- Zooplankton::Resolver
- Defined in:
- lib/zooplankton/resolver.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate(helper_method, helper_name, params = {}) ⇒ Object
- #has_route?(name) ⇒ Boolean
-
#initialize(routes) ⇒ Resolver
constructor
A new instance of Resolver.
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
.instance ⇒ Object
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
13 14 15 |
# File 'lib/zooplankton/resolver.rb', line 13 def has_route?(name) names.include?(name) end |