Sha256: bb0c14cc44a0fd5d8e7899a360b6471da67b4ff1a35c6ca8d9b0655dc0255948
Contents?: true
Size: 1.35 KB
Versions: 2
Compression:
Stored size: 1.35 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_key = "gflash.#{params[:controller]}.#{params[:action]}.#{key}" I18n.t(i18n_key.gsub(/\//, "."), :default => i18n_key.to_sym) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gritter-1.0.3 | lib/gritter/gflash.rb |
gritter-1.0.2 | lib/gritter/gflash.rb |