All Slice code is expected to be namespaced inside a module
Activation hook - runs after AfterAppLoads BootLoader
# File merb-slices/lib/generators/templates/very_thin/lib/%base_name%.rb, line 32 32: def self.activate 33: end
Deactivation hook - triggered by Merb::Slices.deactivate(<%= module_name %>)
# File merb-slices/lib/generators/templates/very_thin/lib/%base_name%.rb, line 36 36: def self.deactivate 37: end
Initialization hook - runs before AfterAppLoads BootLoader
# File merb-slices/lib/generators/templates/very_thin/lib/%base_name%.rb, line 28 28: def self.init 29: end
This sets up a very thin slice‘s structure.
# File merb-slices/lib/generators/templates/very_thin/lib/%base_name%.rb, line 54 54: def self.setup_default_structure! 55: self.push_app_path(:root, Merb.root / 'slices' / self.identifier, nil) 56: 57: self.push_path(:stub, root_path('stubs'), nil) 58: self.push_app_path(:stub, app_dir_for(:root), nil) 59: 60: self.push_path(:application, root, 'application.rb') 61: self.push_app_path(:application, app_dir_for(:root), 'application.rb') 62: 63: self.push_path(:public, root_path('public'), nil) 64: self.push_app_path(:public, Merb.root / 'public' / 'slices' / self.identifier, nil) 65: 66: public_components.each do |component| 67: self.push_path(component, dir_for(:public) / "#{component}s", nil) 68: self.push_app_path(component, app_dir_for(:public) / "#{component}s", nil) 69: end 70: end
Setup routes inside the host application
@param scope<Merb::Router::Behaviour>
Routes will be added within this scope (namespace). In fact, any router behaviour is a valid namespace, so you can attach routes at any level of your router setup.
@note prefix your named routes with :<%= symbol_name %>_
to avoid potential conflicts with global named routes.
# File merb-slices/lib/generators/templates/very_thin/lib/%base_name%.rb, line 48 48: def self.setup_router(scope) 49: # enable slice-level default routes by default 50: scope.default_routes 51: end