Reference this controller’s slice module directly.
@return <Module> A slice module.
# File lib/merb-slices/controller_mixin.rb, line 122 def slice; self.class.slice; end
Generate a url - takes the slice’s :path_prefix into account.
@param *args
There are several possibilities regarding arguments: - when passing a Hash only, the :default route of the current slice will be used - when a single Symbol is passed, it's used as the route name, while the slice itself will be the current one - when two Symbols are passed, the first will be the slice name, the second will be the route name - a Hash with additional params can optionally be passed
@return <String> A uri based on the requested slice.
@example slice_url(:controller => ‘foo’, :action => ‘bar’) @example slice_url(:awesome, :format => ‘html’) @example slice_url(:forum, :posts, :format => ‘xml’)
# File lib/merb-slices/controller_mixin.rb, line 141 def slice_url(*args) opts = args.last.is_a?(Hash) ? args.pop : {} slice_name, route_name = if args[0].is_a?(Symbol) && args[1].is_a?(Symbol) [args.shift, args.shift] # other slice identifier, route name elsif args[0].is_a?(Symbol) [slice.identifier_sym, args.shift] # self, route name else [slice.identifier_sym, :default] # self, default route end routes = Merb::Slices.named_routes[slice_name] unless routes && route = routes[route_name] raise Merb::Router::GenerationError, "Named route not found: #{route_name}" end args.push(opts) route.generate(args, params) end
Generated with the Darkfish Rdoc Generator 2.