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.
Instance Method Summary collapse
-
#load_cookies_manager ⇒ Object
Sets up a before filter that creates a new CookiesManager into an instance variable, which is made available to all views through the
cookies_manager
helper method.
Instance Method Details
#load_cookies_manager ⇒ Object
Sets up a before filter that creates a new CookiesManager into an instance variable,
which is made available to all views through the cookies_manager
helper method.
You can call this method on your controller class as follows:
class YourController < ApplicationController
load_cookies_manager
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/cookies_manager/controller_additions.rb', line 15 def self.before_filter do |controller| # defines a CookiesManager instance variable, based on the cookies hash controller.instance_variable_set(:@_cookies_manager, CookiesManager::Base.new(controller.instance_eval { } )) # wraps the instance variable in a the +cookies_manager+ method define_method :cookies_manager, proc { controller.instance_variable_get(:@_cookies_manager) } # makes the +cookies_manager+ method available to all views as a helper method helper_method :cookies_manager end end |