Sha256: fd94f248dc27c9542b9e018d26a4b71d0c24e9f8b2ebc3cad52e08d1fbc0f620
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module Gritter module Gflash def redirect_to(options = {}, response_status_and_flash = {}) if response_status_and_flash.has_key?(:gflash) gflash(response_status_and_flash[:gflash]) response_status_and_flash.delete(:gflash) end super(options, response_status_and_flash) end def gflash *args session[:gflash] ||= {} options = args.extract_options! if args.present? args.each do |key| gflash_push(key, gflash_translation(key)) end end options.each do |key, value| if value.is_a?(Hash) if value.has_key?(:value) value[:value] = gflash_text(key, value[:value]) else value[:value] = gflash_translation(key) end else value = gflash_text(key, value) end gflash_push(key, value) end end private def gflash_text(key, value) value == true ? gflash_translation(key) : value end def gflash_push(key, value) session[:gflash][key] ||= [] session[:gflash][key].push(value) end def gflash_translation(key) I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gritter-1.0.1 | lib/gritter/gflash.rb |
gritter-1.0.0 | lib/gritter/gflash.rb |