def add_slice(slice_module, options = {}, &block)
if Merb::Slices.exists?(slice_module)
options = { :path => options } if options.is_a?(String)
slice_module = Object.full_const_get(slice_module.to_s.camel_case) if slice_module.class.in?(String, Symbol)
namespace = options[:namespace] || slice_module.identifier_sym
options[:path] ||= options[:path_prefix] || slice_module[:path_prefix] || options[:namespace] || slice_module.identifier
options[:prepend_routes] = block if block_given?
slice_module[:path_prefix] = options[:path]
Merb.logger.verbose!("Mounting slice #{slice_module} at /#{options[:path]}")
@options[:controller_prefix] = nil if options.delete(:reset_controller_prefix)
self.namespace(namespace, options.except(:default_routes, :prepend_routes, :append_routes, :path_prefix)) do |ns|
Merb::Slices.named_routes[slice_module.identifier_sym] = ns.capture do
options[:prepend_routes].call(ns) if options[:prepend_routes].respond_to?(:call)
slice_module.setup_router(ns)
options[:append_routes].call(ns) if options[:append_routes].respond_to?(:call)
end
end
else
Merb.logger.info!("Skipped adding slice #{slice_module} to router...")
end
self
end