Changeset 3581
- Timestamp:
- 02/12/06 06:11:17 (3 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/components.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/flash.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/components.rb
r3580 r3581 52 52 alias_method :set_session_options_without_components, :set_session_options 53 53 alias_method :set_session_options, :set_session_options_with_components 54 55 alias_method :flash_without_components, :flash 56 alias_method :flash, :flash_with_components 54 57 end 55 58 … … 109 112 end 110 113 end 114 end 115 116 def flash_with_components(refresh = false) 117 if @flash.nil? || refresh 118 @flash = 119 if @parent_controller 120 @parent_controller.flash 121 else 122 flash_without_components 123 end 124 end 125 126 @flash 111 127 end 112 128 trunk/actionpack/lib/action_controller/flash.rb
r3580 r3581 29 29 30 30 base.class_eval do 31 alias_method :assign_shortcuts_without_flash, :assign_shortcuts 32 alias_method :assign_shortcuts, :assign_shortcuts_with_flash 33 31 34 alias_method :process_cleanup_without_flash, :process_cleanup 32 35 alias_method :process_cleanup, :process_cleanup_with_flash … … 36 39 37 40 class FlashNow #:nodoc: 38 def initialize flash41 def initialize(flash) 39 42 @flash = flash 40 43 end … … 135 138 136 139 module InstanceMethods 140 def assign_shortcuts_with_flash(request, response) #:nodoc: 141 assign_shortcuts_without_flash(request, response) 142 flash(:refresh) 143 end 144 137 145 def process_cleanup_with_flash 138 146 process_cleanup_without_flash … … 144 152 # <tt>flash["notice"] = "hello"</tt> to put a new one. 145 153 # Note that if sessions are disabled only flash.now will work. 146 def flash #:doc: 147 @flash ||= 148 if @parent_controller 149 @parent_controller.flash 150 elsif @session.is_a?(Hash) 151 # @session is a Hash, if sessions are disabled 152 # we don't put the flash in the session in this case 153 FlashHash.new 154 else 155 # otherwise, @session is a CGI::Session or a TestSession 156 # so make sure it gets retrieved from/saved to session storage after request processing 157 @session["flash"] ||= FlashHash.new 158 end 154 def flash(refresh = false) #:doc: 155 if @flash.nil? || refresh 156 @flash = 157 if @session.is_a?(Hash) 158 # @session is a Hash, if sessions are disabled 159 # we don't put the flash in the session in this case 160 FlashHash.new 161 else 162 # otherwise, @session is a CGI::Session or a TestSession 163 # so make sure it gets retrieved from/saved to session storage after request processing 164 @session["flash"] ||= FlashHash.new 165 end 166 end 167 168 @flash 159 169 end 160 170