router_ext.rb

Path: lib/merb-slices/router_ext.rb
Last Update: Sun Mar 01 20:41:40 -0700 2009

Methods

Public Instance methods

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

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.

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]