Module: CacheableFlash

Includes:
CookieFlash
Defined in:
lib/cacheable_flash/config.rb,
lib/cacheable_flash.rb,
lib/cacheable_flash/engine.rb,
lib/cacheable_flash/railtie.rb,
lib/cacheable_flash/version.rb,
lib/cacheable_flash/middleware.rb,
lib/cacheable_flash/cookie_flash.rb,
lib/cacheable_flash/test_helpers.rb,
lib/cacheable_flash/rspec_matchers.rb,
lib/generators/cacheable_flash/install/install_generator.rb

Overview

Add cacheable flash JS to defaults for Rails < 3.1 (not needed with asset pipeline)

Defined Under Namespace

Modules: CookieFlash, RspecMatchers, TestHelpers Classes: Config, Engine, InstallGenerator, Middleware, Railtie

Constant Summary collapse

VERSION =
"0.3.2"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CookieFlash

#cookie_flash

Class Method Details

.included(base) ⇒ Object



25
26
27
28
# File 'lib/cacheable_flash.rb', line 25

def self.included(base)
  #base must define around_filter, as in Rails
  base.around_filter :write_flash_to_cookie
end

.stackingObject

simply abstracts the StackableFlash.stacking method



42
43
44
# File 'lib/cacheable_flash.rb', line 42

def self.stacking
  StackableFlash.stacking
end

Instance Method Details



30
31
32
33
34
35
36
37
38
39
# File 'lib/cacheable_flash.rb', line 30

def write_flash_to_cookie
  yield if block_given?

  # Base must define cookies, as in Rails
  cookies['flash'] = cookie_flash(flash, cookies)
  # Base must define flash, as in Rails
  # TODO: Does not support flash.now feature of the FlashHash in Rails, 
  #       because flashes are only removed from cookies when they are used.
  flash.clear
end