Module: ActionController::Routing::NamedRoutes
- Defined in:
- lib/action_controller/routing.rb
Overview
:nodoc:
Constant Summary collapse
- Helpers =
[]
Class Method Summary collapse
- .clear ⇒ Object
- .hash_access_name(name) ⇒ Object
- .install(cls = ActionController::Base) ⇒ Object
- .name_route(route, name) ⇒ Object
- .url_helper_name(name) ⇒ Object
Class Method Details
.clear ⇒ Object
576 |
# File 'lib/action_controller/routing.rb', line 576 def clear() Helpers.clear end |
.hash_access_name(name) ⇒ Object
578 579 580 |
# File 'lib/action_controller/routing.rb', line 578 def hash_access_name(name) "hash_for_#{name}_url" end |
.install(cls = ActionController::Base) ⇒ Object
601 602 603 604 605 606 607 608 |
# File 'lib/action_controller/routing.rb', line 601 def install(cls = ActionController::Base) cls.send :include, self if cls.respond_to? :helper_method Helpers.each do |helper_name| cls.send :helper_method, helper_name end end end |
.name_route(route, name) ⇒ Object
586 587 588 589 590 591 592 593 594 595 596 597 598 599 |
# File 'lib/action_controller/routing.rb', line 586 def name_route(route, name) hash = route.defaults.merge(route.known).symbolize_keys hash[:controller] = "/#{hash[:controller]}" define_method(hash_access_name(name)) { hash } module_eval(%{def #{url_helper_name name}(options = {}) url_for(#{hash_access_name(name)}.merge(options)) end}, "generated/routing/named_routes/#{name}.rb") protected url_helper_name(name), hash_access_name(name) Helpers << url_helper_name(name).to_sym Helpers.uniq! end |
.url_helper_name(name) ⇒ Object
582 583 584 |
# File 'lib/action_controller/routing.rb', line 582 def url_helper_name(name) "#{name}_url" end |