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

NOTE: the CacheableFlash::Config class is experimental, and no code uses the config settings yet. So using config values will do nothing as of now. These are ust some ideas of what could be…

Defined Under Namespace

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

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CookieFlash

#cookie_flash

Class Method Details

.included(base) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cacheable_flash.rb', line 25

def self.included(base)
  #base must define around_action or around_filter, as in Rails

  around_method = if base.respond_to?(:around_action)
    :around_action
  else
    :around_filter
  end

  base.send around_method, :write_flash_to_cookie
end

.stackingObject

simply abstracts the StackableFlash.stacking method


51
52
53
# File 'lib/cacheable_flash.rb', line 51

def self.stacking
  StackableFlash.stacking
end

Instance Method Details


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cacheable_flash.rb', line 37

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