Class: ActionDispatch::Journey::Routes
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Instance Chain:
|
|
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/journey/routes.rb |
Overview
The Routing table. Contains all routes for a system. Routes
can be added to the table by calling #add_route.
Class Method Summary
- .new(routes = []) ⇒ Routes constructor
Instance Attribute Summary
- #anchored_routes readonly
- #custom_routes readonly
- #empty? ⇒ Boolean readonly
- #routes readonly
::Enumerable
- Included
#many? | Returns |
Instance Method Summary
- #add_route(name, mapping)
- #ast
- #clear
- #each(&block)
- #last
- #length (also: #size)
- #partition_route(route)
- #simulator
-
#size
Alias for #length.
- #clear_cache! private
::Enumerable
- Included
#compact_blank | Returns a new |
#exclude? | The negative of the |
#excluding | Returns a copy of the enumerable excluding the specified elements. |
#in_order_of | Returns a new |
#including | Returns a new array that includes the passed elements. |
#index_by | Convert an enumerable to a hash, using the block result as the key and the element as the value. |
#index_with | Convert an enumerable to a hash, using the element as the key and the block result as the value. |
#maximum | Calculates the maximum from the extracted elements. |
#minimum | Calculates the minimum from the extracted elements. |
#pick | Extract the given key from the first element in the enumerable. |
#pluck | Extract the given key from each element in the enumerable. |
#sole | Returns the sole item in the enumerable. |
#without | Alias for Enumerable#excluding. |
#as_json |
::ActiveSupport::EnumerableCoreExt::Constants
- Included
Constructor Details
.new(routes = []) ⇒ Routes
Instance Attribute Details
#anchored_routes (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 12
attr_reader :routes, :custom_routes, :anchored_routes
#custom_routes (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 12
attr_reader :routes, :custom_routes, :anchored_routes
#empty? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 22
def empty? routes.empty? end
#routes (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 12
attr_reader :routes, :custom_routes, :anchored_routes
Instance Method Details
#add_route(name, mapping)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 67
def add_route(name, mapping) route = mapping.make_route name, routes.length routes << route partition_route(route) clear_cache! route end
#ast
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 53
def ast @ast ||= begin nodes = anchored_routes.map(&:ast) Nodes::Or.new(nodes) end end
#clear
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 39
def clear routes.clear anchored_routes.clear custom_routes.clear end
#clear_cache! (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 76
def clear_cache! @ast = nil @simulator = nil end
#each(&block)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 35
def each(&block) routes.each(&block) end
#last
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 31
def last routes.last end
#length Also known as: #size
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 26
def length routes.length end
#partition_route(route)
[ GitHub ]# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 45
def partition_route(route) if route.path.anchored && route.path.requirements_anchored? anchored_routes << route else custom_routes << route end end
#simulator
[ GitHub ]#size
Alias for #length.
# File 'actionpack/lib/action_dispatch/journey/routes.rb', line 29
alias :size :length