Sha256: d9a6abf68c695c17ea18e32470bccf138d59104acc11c500d93656a2eef7fd61

Contents?: true

Size: 763 Bytes

Versions: 1

Compression:

Stored size: 763 Bytes

Contents

module Rad
  class Flash < OpenObject
    attr_accessor :previous_messages, :current_messages
        
    def initialize format, previous_messages = {}
      self.current_messages, self.previous_messages = {}, previous_messages
      @keep = false
    end
    
    def [] key
      key = key.to_s
      
      if keep?
        previous_messages[key]        
      else
        current_messages[key] || previous_messages[key]
      end
    end
    
    def []= key, value
      current_messages[key.to_s] = value.to_s
    end
    
    def keep!
      @keep = true
      self
    end
    
    def keep?
      !!@keep
    end

    def messages_for_next_request
      if keep?
        current_messages
      else        
        {}
      end
    end
      
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rad_core-0.0.13 lib/rad/html/flash.rb