Module: Merb::Slices::ControllerMixin::MixinMethods::InstanceMethods
- Defined in:
- lib/merb-slices/controller_mixin.rb
Instance Method Summary collapse
-
#slice ⇒ Module
Reference this controller’s slice module directly.
-
#slice_url(*args) ⇒ String
Generate a url - takes the slice’s :path_prefix into account.
Instance Method Details
#slice ⇒ Module
Reference this controller’s slice module directly.
122 |
# File 'lib/merb-slices/controller_mixin.rb', line 122 def slice; self.class.slice; end |
#slice_url(*args) ⇒ String
Generate a url - takes the slice’s :path_prefix into account.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# 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 |