Class: Innate::Session::Flash

### Home Classes Methods

### In Files

- lib/innate/session/flash.rb

### Parent

Object

### Methods

- ::new
- #[]
- #[]=
- #combined
- #current
- #delete
- #each
- #empty?
- #inspect
- #merge
- #merge!
- #previous
- #rotate!

### Included Modules

- Enumerable

### Class/Module Index

Quicksearch

- Innate
- Innate::Action
- Innate::Adapter
- Innate::Cache
- Innate::Cache::API
- Innate::Cache::DRb
- Innate::Cache::FileBased
- Innate::Cache::Marshal
- Innate::Cache::Memory
- Innate::Cache::YAML
- Innate::Current
- Innate::Etanni
- Innate::Helper
- Innate::Helper::Aspect
- Innate::Helper::Aspect::SingletonMethods
- Innate::Helper::CGI
- Innate::Helper::Flash
- Innate::Helper::Link
- Innate::Helper::Redirect
- Innate::Helper::Render
- Innate::HelperAccess
- Innate::HelpersHelper
- Innate::LRUHash
- Innate::LogHub
- Innate::Mock
- Innate::Mock::Session
- Innate::Node
- Innate::Optioned
- Innate::Optioned::SingletonMethods
- Innate::Options
- Innate::Request
- Innate::Response
- Innate::Rewrite
- Innate::Route
- Innate::Session
- Innate::Session::Flash
- Innate::SingletonMethods
- Innate::StateAccessor
- Innate::Traited
- Innate::Trinity
- Innate::URLMap
- Innate::View
- Innate::View::ERB
- Innate::View::Etanni
- Innate::View::None
- Logger
- Logger::ColorFormatter
- Object

No matching classes.

# Innate::Session::Flash

The purpose of this class is to act as a unifier of the previous and current flash.

Flash means pairs of keys and values that are held only over one request/response cycle. So you can assign a key/value in the current session and retrieve it in the current and following request.

Please see the Innate::Helper::Flash for details on the usage in your application.

### Public Class Methods

new(session) click to toggle source

    # File lib/innate/session/flash.rb, line 16
    def initialize(session)
      @session = session
    end

### Public Instance Methods

[](key) click to toggle source

flash in your Controller

    # File lib/innate/session/flash.rb, line 42
    def [](key)
      combined[key]
    end

[]=(key, value) click to toggle source

flash = value in your Controller

    # File lib/innate/session/flash.rb, line 47
    def []=(key, value)
      prev = session[:FLASH] || {}
      prev[key] = value
      session[:FLASH] = prev
    end

combined() click to toggle source

combined key/value pairs of previous and current current keys overshadow the old ones.

    # File lib/innate/session/flash.rb, line 37
    def combined
      previous.merge(current)
    end

current() click to toggle source

the current session

    # File lib/innate/session/flash.rb, line 31
    def current
      session[:FLASH] ||= {}
    end

delete(key) click to toggle source

Delete a key

    # File lib/innate/session/flash.rb, line 59
    def delete(key)
      previous.delete(key)
      current.delete(key)
    end

each(&block) click to toggle source

iterate over the combined session

    # File lib/innate/session/flash.rb, line 21
    def each(&block)
      combined.each(&block)
    end

empty?() click to toggle source

check if combined is empty

    # File lib/innate/session/flash.rb, line 65
    def empty?
      combined.empty?
    end

inspect() click to toggle source

Inspects combined

    # File lib/innate/session/flash.rb, line 54
    def inspect
      combined.inspect
    end

merge(hash) click to toggle source

merge on current

    # File lib/innate/session/flash.rb, line 75
    def merge(hash)
      current.merge(hash)
    end

merge!(hash) click to toggle source

merge into current

    # File lib/innate/session/flash.rb, line 70
    def merge!(hash)
      current.merge!(hash)
    end

previous() click to toggle source

the current session

    # File lib/innate/session/flash.rb, line 26
    def previous
      session[:FLASH_PREVIOUS] || {}
    end

rotate!() click to toggle source

Rotation means current values are assigned as old values for the next request.

    # File lib/innate/session/flash.rb, line 81
    def rotate!
      old = session.delete(:FLASH)
      session[:FLASH_PREVIOUS] = old if old
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.