%base_name%.rb

Path: merb-slices/lib/generators/templates/thin/lib/%base_name%.rb
Last Update: Tue Jul 28 06:32:52 +0000 2009

Methods

Public Class methods

Activation hook - runs after AfterAppLoads BootLoader

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 33
33:     def self.activate
34:     end

Deactivation hook - triggered by Merb::Slices.deactivate(<%= module_name %>)

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 37
37:     def self.deactivate
38:     end

Initialization hook - runs before AfterAppLoads BootLoader

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 29
29:     def self.init
30:     end

Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice‘s classes have been loaded internally.

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 25
25:     def self.loaded
26:     end

This sets up a thin slice‘s structure.

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 55
55:     def self.setup_default_structure!
56:       self.push_app_path(:root, Merb.root / 'slices' / self.identifier, nil)
57:       
58:       self.push_path(:stub, root_path('stubs'), nil)
59:       self.push_app_path(:stub, app_dir_for(:root), nil)
60:       
61:       self.push_path(:application, root, 'application.rb')
62:       self.push_app_path(:application, app_dir_for(:root), 'application.rb')
63:       
64:       self.push_path(:view, dir_for(:application) / "views")
65:       self.push_app_path(:view, app_dir_for(:application) / "views")
66:       
67:       self.push_path(:public, root_path('public'), nil)
68:       self.push_app_path(:public, Merb.root / 'public' / 'slices' / self.identifier, nil)
69:       
70:       public_components.each do |component|
71:         self.push_path(component, dir_for(:public) / "#{component}s", nil)
72:         self.push_app_path(component, app_dir_for(:public) / "#{component}s", nil)
73:       end
74:     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.

[Source]

    # File merb-slices/lib/generators/templates/thin/lib/%base_name%.rb, line 49
49:     def self.setup_router(scope)
50:       # enable slice-level default routes by default
51:       scope.default_routes
52:     end

[Validate]