Class: Mapper
- Inherits:
-
Object
- Object
- Mapper
- Defined in:
- lib/middleman-router/mapper.rb
Defined Under Namespace
Classes: Resource
Instance Method Summary collapse
-
#initialize(set) ⇒ Mapper
constructor
Initialize the Mapper.
-
#route(*args, &block) ⇒ Object
Route Creates a new route and any child routes.
Constructor Details
#initialize(set) ⇒ Mapper
Initialize the Mapper
20 21 22 23 |
# File 'lib/middleman-router/mapper.rb', line 20 def initialize(set) @set = set @resources = [] end |
Instance Method Details
#route(*args, &block) ⇒ Object
Route Creates a new route and any child routes
Usage: route :about_us, path: “about-us”, as: “about”
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/middleman-router/mapper.rb', line 29 def route(*args, &block) resource = build_resource(args, @scope) if resource.enabled? @set.add_route(resource.route_name, resource.path) end # If a block is passed, then let's create routes # for each child route in the block # if block_given? previous_scope = @scope @scope = resource self.instance_exec(&block) @scope = previous_scope end end |