Module: MerbAuthSliceActivation

Defined in:
lib/merb-auth-slice-activation.rb

Overview

All Slice code is expected to be namespaced inside a module

Defined Under Namespace

Classes: ActivationMailer, Activations, Application

Class Method Summary collapse

Class Method Details

.activateObject

Activation hook - runs after AfterAppLoads BootLoader



51
52
# File 'lib/merb-auth-slice-activation.rb', line 51

def self.activate
end

.deactivateObject

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



55
56
# File 'lib/merb-auth-slice-activation.rb', line 55

def self.deactivate
end

.initObject

Initialization hook - runs before AfterAppLoads BootLoader



39
40
41
42
43
44
45
46
47
48
# File 'lib/merb-auth-slice-activation.rb', line 39

def self.init
  # Actually check if the user is active 
  ::Merb::Authentication.after_authentication do |user, *rest|
    if user.respond_to?(:active?)
      user.active? ? user : nil
    else 
      user
    end
  end
end

.loadedObject

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



35
36
# File 'lib/merb-auth-slice-activation.rb', line 35

def self.loaded
end

.setup_router(scope) ⇒ Object

Note:

prefix your named routes with :merb_auth_slice_activation_ 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.



67
68
69
# File 'lib/merb-auth-slice-activation.rb', line 67

def self.setup_router(scope)
  scope.match("/activate/:activation_code").to(:controller => "activations", :action => "activate").name(:activate)
end