Class: Rory::RouteMapper
- Inherits:
-
Object
- Object
- Rory::RouteMapper
- Defined in:
- lib/rory/route_mapper.rb
Overview
Route mapper, used to convert the entries in ‘config/routes.rb’ into a routing table for use by the dispatcher.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ RouteMapper
constructor
A new instance of RouteMapper.
- #match(mask, options = {}) ⇒ Object
- #routing_map ⇒ Object
- #scope(options = {}, &block) ⇒ Object
Constructor Details
#initialize ⇒ RouteMapper
Returns a new instance of RouteMapper.
13 14 15 16 |
# File 'lib/rory/route_mapper.rb', line 13 def initialize @routes = [] @scope_options = {} end |
Class Method Details
.set_routes(&block) ⇒ Object
6 7 8 9 10 |
# File 'lib/rory/route_mapper.rb', line 6 def set_routes(&block) mapper = new mapper.instance_exec(&block) mapper.routing_map end |
Instance Method Details
#match(mask, options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/rory/route_mapper.rb', line 29 def match(mask, = {}) .merge!(@scope_options) [:to] ||= mask.split('/').first @routes << Route.new(mask, ) end |
#routing_map ⇒ Object
18 19 20 |
# File 'lib/rory/route_mapper.rb', line 18 def routing_map @routes end |
#scope(options = {}, &block) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rory/route_mapper.rb', line 22 def scope( = {}, &block) , @scope_options = @scope_options, @scope_options.merge() yield @scope_options = end |