lib/gritter/gflash.rb in gritter-0.6.2 vs lib/gritter/gflash.rb in gritter-0.6.3

- old
+ new

@@ -2,10 +2,27 @@ module Gflash def gflash *args session[:gflash] ||= {} options = args.extract_options! options.each do |key, value| - session[:gflash][key] = value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value + if value.is_a?(Hash) + gflash_value = value + gflash_value[:value] = gflash_text(key, gflash_value[:value]) if gflash_value.has_key?(:value) + else + gflash_value = gflash_text(key, value) + end + + if session[:gflash].has_key?(key) + session[:gflash][key].push(gflash_value) + else + session[:gflash][key] = [gflash_value] + end end + end + + private + + def gflash_text(key, value) + value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value end end end \ No newline at end of file