Module: MerbBackground

Defined in:
lib/merb_background.rb

Overview

All Slice code is expected to be namespaced inside a module

Defined Under Namespace

Classes: Application, Job, Main

Constant Summary collapse

Config =
Mash.new(
:cleanup_interval => :on_startup,
:monitor_interval => 10
)

Class Method Summary collapse

Class Method Details

.activateObject

Activation hook - runs after AfterAppLoads BootLoader



44
45
# File 'lib/merb_background.rb', line 44

def self.activate
end

.deactivateObject

Deactivation hook - triggered by Merb::Slices.deactivate(MerbBackground)



48
49
# File 'lib/merb_background.rb', line 48

def self.deactivate
end

.initObject

Initialization hook - runs before AfterAppLoads BootLoader



40
41
# File 'lib/merb_background.rb', line 40

def self.init
end

.loadedObject

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



35
36
37
# File 'lib/merb_background.rb', line 35

def self.loaded
  require 'merb_background/job'
end

.setup_router(scope) ⇒ Object

Note:

prefix your named routes with :merb_background_ to avoid potential conflicts with global named routes.

Setup routes inside the host application

Parameters:

  • 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.



60
61
62
63
64
65
66
67
# File 'lib/merb_background.rb', line 60

def self.setup_router(scope)
  # example of a named route
  scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
  # the slice is mounted at /merb_background - note that it comes before default_routes
  scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
  # enable slice-level default routes by default
  scope.default_routes
end