Module: CacheableFlash

Includes:
CookieFlash
Defined in:
lib/cacheable_flash.rb,
lib/cacheable_flash/engine.rb,
lib/cacheable_flash/config.rb,
lib/cacheable_flash/version.rb,
lib/cacheable_flash/railtie.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

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"0.3.4"

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


44
45
46
# File 'lib/cacheable_flash.rb', line 44

def self.stacking
  StackableFlash.stacking
end

Instance Method Details


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

def write_flash_to_cookie
  yield if block_given?


  # Base must define cookies, as in Rails
  domain = CacheableFlash::Config.config[:domain]
  cookies['flash'] = { :value => cookie_flash(flash, cookies), :domain => domain }
  # 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