Module: Ramaze::Helper::Flash

Includes:
Innate::Traited
Defined in:
lib/ramaze/helper/flash.rb

Instance Method Summary (collapse)

Methods included from Innate::Traited

#ancestral_trait, #ancestral_trait_values, #class_trait, #each_ancestral_trait, included, #trait

Instance Method Details

- (Object) flash

Return the current value of Current.session.flash



32
33
34
# File 'lib/ramaze/helper/flash.rb', line 32

def flash
  Current.session.flash
end

- (Object) flashbox(tag = ancestral_trait[:flashbox])

Use in your template to display all flash messages that may be stored. For example, given you stored:

flash # => { :error => 'Please enter your name' :info => 'Do you see the fnords?' }

Then a flashbox would display:

Please enter your name
Do you see the fnords?

This is designed to be customized permanently or per usage:

flashbox("

%value
")

Where any occurrence of %key and %value will be replaced by the actual contents of each element of flash



53
54
55
56
57
58
59
# File 'lib/ramaze/helper/flash.rb', line 53

def flashbox(tag = ancestral_trait[:flashbox])
  flash.map{|key, *values|
    values.flatten.map do |value|
      tag.gsub(/%key/, key.to_s).gsub(/%value/, value.to_s)
    end
  }.flatten.join("\n")
end