1 if defined?(Merb::Plugins)
3 $:.unshift File.dirname(__FILE__)
5 load_dependency 'merb-slices'
7 #require 'dm-validations'
10 Merb::Plugins.add_rakefiles "merb_mart/merbtasks", "merb_mart/slicetasks", "merb_mart/spectasks"
12 # Register the Slice for the current host application
13 Merb::Slices::register(__FILE__)
15 # Slice configuration - set this in a before_app_loads callback.
16 # By default a Slice uses its own layout, so you can swicht to
17 # the main application layout or no layout at all if needed.
19 # Configuration options:
20 # :layout - the layout to use; defaults to :merb_mart
21 # :mirror - which path component types to use on copy operations; defaults to all
22 Merb::Slices::config[:merb_mart][:layout] ||= :merb_mart
24 # All Slice code is expected to be namespaced inside a module
28 self.description = "MerbMart is a chunky Merb slice!"
29 self.version = "0.0.1"
30 self.author = "YOUR NAME"
32 # Stub classes loaded hook - runs before LoadClasses BootLoader
33 # right after a slice's classes have been loaded internally.
37 # Initialization hook - runs before AfterAppLoads BootLoader
41 # Activation hook - runs after AfterAppLoads BootLoader
45 # Deactivation hook - triggered by Merb::Slices.deactivate(MerbMart)
49 # Setup routes inside the host application
51 # @param scope<Merb::Router::Behaviour>
52 # Routes will be added within this scope (namespace). In fact, any
53 # router behaviour is a valid namespace, so you can attach
54 # routes at any level of your router setup.
56 # @note prefix your named routes with :merb_mart_
57 # to avoid potential conflicts with global named routes.
58 def self.setup_router(scope)
59 scope.namespace(:admin) do |admin|
60 admin.to(:controller => 'products') do |products|
61 products.match('/products').to.name(:products)
64 # example of a named route
65 scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
66 # the slice is mounted at /merb_mart - note that it comes before default_routes
67 scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
68 # enable slice-level default routes by default
74 # Setup the slice layout for MerbMart
76 # Use MerbMart.push_path and MerbMart.push_app_path
77 # to set paths to merb_mart-level and app-level paths. Example:
79 # MerbMart.push_path(:application, MerbMart.root)
80 # MerbMart.push_app_path(:application, Merb.root / 'slices' / 'merb_mart')
83 # Any component path that hasn't been set will default to MerbMart.root
85 # Or just call setup_default_structure! to setup a basic Merb MVC structure.
86 MerbMart.setup_default_structure!
88 # Add dependencies for other MerbMart classes below. Example:
89 # dependency "merb_mart/other"