Module: CookiesManager::ControllerAdditions

Defined in:
lib/cookies_manager/controller_additions.rb

Overview

This module provides a CookiesManager facility for your controllers. It is automatically extended by all controllers.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



31
32
33
# File 'lib/cookies_manager/controller_additions.rb', line 31

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#build_cookies_managerObject

Builds a cookies manager as a controller instance variable, made available to all views



22
23
24
25
26
27
28
29
# File 'lib/cookies_manager/controller_additions.rb', line 22

def build_cookies_manager
  # defines a CookiesManager instance variable, based on the cookies hash
  @_cookies_manager = CookiesManager::Base.new(cookies)
  # wraps the instance variable in the +cookies_manager+ instance method
  define_singleton_method :cookies_manager, proc { @_cookies_manager }
  # makes the +cookies_manager+ method available to all views as a helper method
  self.class.helper_method :cookies_manager
end