Sha256: acfd42bec58fd1e22a4fd1271ebabd7509eb400efd728352fae760e7d750343a

Contents?: true

Size: 635 Bytes

Versions: 4

Compression:

Stored size: 635 Bytes

Contents

module Nyara
  # Convenient thingy that let you can pass instant message to next request.<br>
  # It is consumed as soon as next request arrives.
  class Flash
    def initialize session
      # NOTE no need to convert hash type because Session uses ParamHash for json parsing
      @now = session.delete('flash.next') || ParamHash.new
      session['flash.next'] = @next = ParamHash.new
    end
    attr_reader :now, :next

    def [] key
      @now[key]
    end

    def []= key, value
      @next[key] = value
    end

    # Clear both `flash.now` and `flash.next`
    def clear
      @now.clear
      @next.clear
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nyara-0.1.pre.2 lib/nyara/flash.rb
nyara-0.1.pre.1 lib/nyara/flash.rb
nyara-0.1.pre.0 lib/nyara/flash.rb
nyara-0.0.1.pre.9 lib/nyara/flash.rb