Class: ActionController::Routing::RouteSet::NamedRouteCollection
- Includes:
- Enumerable
- Defined in:
- lib/action_controller/routing.rb
Overview
A NamedRouteCollection instance is a collection of named routes, and also maintains an anonymous module that can be used to install helpers for the named routes.
Instance Attribute Summary collapse
-
#helpers ⇒ Object
readonly
Returns the value of attribute helpers.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #add(name, route) ⇒ Object (also: #[]=)
- #clear! ⇒ Object (also: #clear)
- #each ⇒ Object
- #get(name) ⇒ Object (also: #[])
-
#initialize ⇒ NamedRouteCollection
constructor
A new instance of NamedRouteCollection.
- #install(destinations = [ActionController::Base, ActionView::Base]) ⇒ Object
- #length ⇒ Object
- #names ⇒ Object
Constructor Details
#initialize ⇒ NamedRouteCollection
Returns a new instance of NamedRouteCollection.
1004 1005 1006 |
# File 'lib/action_controller/routing.rb', line 1004 def initialize clear! end |
Instance Attribute Details
#helpers ⇒ Object (readonly)
Returns the value of attribute helpers.
1002 1003 1004 |
# File 'lib/action_controller/routing.rb', line 1002 def helpers @helpers end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
1002 1003 1004 |
# File 'lib/action_controller/routing.rb', line 1002 def routes @routes end |
Instance Method Details
#add(name, route) ⇒ Object Also known as: []=
1018 1019 1020 1021 |
# File 'lib/action_controller/routing.rb', line 1018 def add(name, route) routes[name.to_sym] = route define_named_route_methods(name, route) end |
#clear! ⇒ Object Also known as: clear
1008 1009 1010 1011 1012 1013 1014 1015 1016 |
# File 'lib/action_controller/routing.rb', line 1008 def clear! @routes = {} @helpers = [] @module ||= Module.new @module.instance_methods.each do |selector| @module.send :remove_method, selector end end |
#each ⇒ Object
1031 1032 1033 1034 |
# File 'lib/action_controller/routing.rb', line 1031 def each routes.each { |name, route| yield name, route } self end |
#get(name) ⇒ Object Also known as: []
1023 1024 1025 |
# File 'lib/action_controller/routing.rb', line 1023 def get(name) routes[name.to_sym] end |
#install(destinations = [ActionController::Base, ActionView::Base]) ⇒ Object
1044 1045 1046 |
# File 'lib/action_controller/routing.rb', line 1044 def install(destinations = [ActionController::Base, ActionView::Base]) Array(destinations).each { |dest| dest.send :include, @module } end |
#length ⇒ Object
1040 1041 1042 |
# File 'lib/action_controller/routing.rb', line 1040 def length routes.length end |
#names ⇒ Object
1036 1037 1038 |
# File 'lib/action_controller/routing.rb', line 1036 def names routes.keys end |