aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/base.rb
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-03-01 14:10:53 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-03-01 14:10:53 -0800
commit8fbbdda52634991b047b7567fe3a8ec7c9a6c558 (patch)
treefefe6fe2dd56df41e2d65fca03a620c3c601b2f1 /actionpack/lib/action_view/base.rb
parent2060977b767061a42eb8db2d5c3a30d205a94123 (diff)
downloadrails-8fbbdda52634991b047b7567fe3a8ec7c9a6c558.tar.gz
rails-8fbbdda52634991b047b7567fe3a8ec7c9a6c558.tar.bz2
rails-8fbbdda52634991b047b7567fe3a8ec7c9a6c558.zip
Delegate formats to the controller
Diffstat (limited to 'actionpack/lib/action_view/base.rb')
-rw-r--r--actionpack/lib/action_view/base.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index a61017ae11..2d2b53a6ce 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -186,12 +186,21 @@ module ActionView #:nodoc:
extend ActiveSupport::Memoizable
- attr_accessor :base_path, :assigns, :template_extension, :formats
+ attr_accessor :base_path, :assigns, :template_extension
attr_internal :captures
def reset_formats(formats)
- @formats = formats
+ old_formats, self.formats = self.formats, formats
+ reset_hash_key
+ yield if block_given?
+ ensure
+ if block_given?
+ self.formats = old_formats
+ reset_hash_key
+ end
+ end
+ def reset_hash_key
if defined?(AbstractController::HashKey)
# This is expensive, but we need to reset this when the format is updated,
# which currently only happens
@@ -200,6 +209,18 @@ module ActionView #:nodoc:
end
end
+ def formats
+ controller ? controller.formats : @formats
+ end
+
+ def formats=(val)
+ if controller
+ controller.formats = val
+ else
+ @formats = val
+ end
+ end
+
class << self
delegate :erb_trim_mode=, :to => 'ActionView::Template::Handlers::ERB'
delegate :logger, :to => 'ActionController::Base', :allow_nil => true