File: router_ext.rb

# router_ext.rb

Path: | lib/merb-slices/router_ext.rb
Last Update: | Fri Mar 19 08:48:50 -0600 2010

### Methods

add_slice add_slices all_slices slice

### Public Instance methods

add_slice(slice_module, options = {}, &block)

Add a Slice in a router namespace

@param slice_module<String, Symbol, Module> A Slice module to mount. @param options<Hash, String> Optional hash, set :path if you want to override what appears on the url.

@yield A new Behavior instance is yielded in the block for nested routes - runs before the slice routes are setup. @yieldparam ns<Behavior> The namespace behavior object.

@return <Behaviour> The current router context.

@note If a slice has no routes at all, the activate hook won‘t be executed.

@note Normally you should specify the slice_module using a String or Symbol

          this ensures that your module can be removed from the router at runtime.

add_slices(config = {}, &block)

Alias for all_slices

all_slices(config = {}, &block)

Add all known slices to the router

By combining this with Merb::Slices.activate_by_file and Merb::Slices.deactivate one can enable/disable slices at runtime, without restarting your app.

@param config<Hash>

     Optional hash, mapping slice module names to their settings;
     set :path (or use a string) if you want to override what appears on the url.

@yield A new Behavior instance is yielded in the block for nested routes. @yieldparam ns<Behavior> The namespace behavior object.

@example all_slices(‘BlogSlice’ => ‘blog’, ‘ForumSlice’ => { :path => ‘forum’ })

@note The block is yielded for each slice individually.

slice(slice_module, options = {}, &block)

Insert a slice directly into the current router context.

This will still setup a namespace, but doesn‘t set a path prefix. Only for special cases.

[Validate]