Sha256: dfde019dbb5c50b5ab9f6ae856329e0811d27ad72215c0fda661f9e9d8fe69e4

Contents?: true

Size: 667 Bytes

Versions: 24

Compression:

Stored size: 667 Bytes

Contents

class Rad::Html::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

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 lib/rad/html/_flash.rb
rad_core-0.2.5 lib/rad/html/_flash.rb
rad_core-0.2.4 lib/rad/html/_flash.rb
rad_core-0.2.3 lib/rad/html/_flash.rb
rad_core-0.2.2 lib/rad/html/_flash.rb
rad_core-0.2.1 lib/rad/html/_flash.rb
rad_core-0.2.0 lib/rad/html/_flash.rb
rad_core-0.0.30 lib/rad/html/_flash.rb
rad_core-0.0.29 lib/rad/html/_flash.rb
rad_core-0.0.28 lib/rad/html/_flash.rb
rad_core-0.0.27 lib/rad/html/_flash.rb
rad_core-0.0.26 lib/rad/html/_flash.rb
rad_core-0.0.25 lib/rad/html/_flash.rb
rad_core-0.0.24 lib/rad/html/_flash.rb
rad_core-0.0.23 lib/rad/html/_flash.rb
rad_core-0.0.22 lib/rad/html/_flash.rb
rad_core-0.0.21 lib/rad/html/_flash.rb
rad_core-0.0.20 lib/rad/html/_flash.rb
rad_core-0.0.19 lib/rad/html/_flash.rb
rad_core-0.0.18 lib/rad/html/_flash.rb