aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-12-16 01:00:48 -0600
committerJoshua Peek <josh@joshpeek.com>2008-12-16 01:00:48 -0600
commit7c090509994faa19fcbd534aa78324b70b659627 (patch)
tree3ad666fb1b59de3d5fd06744729e4d77e8347c23 /actionpack
parent9a733f6c640cb3c4d474ecf44dd62ab73e351fd5 (diff)
downloadrails-7c090509994faa19fcbd534aa78324b70b659627.tar.gz
rails-7c090509994faa19fcbd534aa78324b70b659627.tar.bz2
rails-7c090509994faa19fcbd534aa78324b70b659627.zip
Lazy load flash access
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/flash.rb22
-rw-r--r--actionpack/lib/action_controller/test_process.rb2
2 files changed, 14 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index 6378a7f25b..9856dbed2a 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -27,8 +27,8 @@ module ActionController #:nodoc:
def self.included(base)
base.class_eval do
include InstanceMethods
- alias_method_chain :assign_shortcuts, :flash
- alias_method_chain :reset_session, :flash
+ alias_method_chain :perform_action, :flash
+ alias_method_chain :reset_session, :flash
end
end
@@ -135,22 +135,26 @@ module ActionController #:nodoc:
module InstanceMethods #:nodoc:
protected
+ def perform_action_with_flash
+ perform_action_without_flash
+ remove_instance_variable(:@_flash) if defined? @_flash
+ end
+
def reset_session_with_flash
reset_session_without_flash
- remove_instance_variable(:@_flash)
+ remove_instance_variable(:@_flash) if defined? @_flash
end
# Access the contents of the flash. Use <tt>flash["notice"]</tt> to
# read a notice you put there or <tt>flash["notice"] = "hello"</tt>
# to put a new one.
def flash #:doc:
- @_flash ||= session["flash"] ||= FlashHash.new
- end
+ unless defined? @_flash
+ @_flash = session["flash"] ||= FlashHash.new
+ @_flash.sweep
+ end
- private
- def assign_shortcuts_with_flash(request, response) #:nodoc:
- assign_shortcuts_without_flash(request, response)
- flash.sweep if @_session
+ @_flash
end
end
end
diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb
index c35c3c07e8..c613d6b862 100644
--- a/actionpack/lib/action_controller/test_process.rb
+++ b/actionpack/lib/action_controller/test_process.rb
@@ -232,7 +232,7 @@ module ActionController #:nodoc:
# Do we have a flash?
def has_flash?
- !session['flash'].empty?
+ !flash.empty?
end
# Do we have a flash that has contents?