Module: ActionController::Routing::NamedRoutes

Defined in:
lib/action_controller/routing.rb

Overview

:nodoc:

Constant Summary collapse

Helpers =
[]

Class Method Summary collapse

Class Method Details

.clearObject



568
# File 'lib/action_controller/routing.rb', line 568

def clear() Helpers.clear end

.hash_access_name(name) ⇒ Object



570
571
572
# File 'lib/action_controller/routing.rb', line 570

def hash_access_name(name)
  "hash_for_#{name}_url"
end

.install(cls = ActionController::Base) ⇒ Object



593
594
595
596
597
598
599
600
# File 'lib/action_controller/routing.rb', line 593

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



578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/action_controller/routing.rb', line 578

def name_route(route, name)
  hash = 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



574
575
576
# File 'lib/action_controller/routing.rb', line 574

def url_helper_name(name)
  "#{name}_url"
end