aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-22 10:18:19 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-22 10:19:01 -0600
commit1a750da130223867195503d284cf4c73a345eee5 (patch)
treec73815d1d84e8c1f4bceb2e86fea458ea5c3abf1
parent4afd9702fe111a5cbaa0d9572e7661c90b188d49 (diff)
downloadrails-1a750da130223867195503d284cf4c73a345eee5.tar.gz
rails-1a750da130223867195503d284cf4c73a345eee5.tar.bz2
rails-1a750da130223867195503d284cf4c73a345eee5.zip
Make @controller an internal ivar in the view
-rw-r--r--actionpack/lib/action_view/base.rb14
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb8
-rw-r--r--actionpack/lib/action_view/helpers/cache_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb12
4 files changed, 17 insertions, 19 deletions
diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb
index 4970c768e8..c4b0455c2a 100644
--- a/actionpack/lib/action_view/base.rb
+++ b/actionpack/lib/action_view/base.rb
@@ -181,7 +181,6 @@ module ActionView #:nodoc:
extend ActiveSupport::Memoizable
attr_accessor :base_path, :assigns, :template_extension, :formats
- attr_accessor :controller
attr_internal :captures
def reset_formats(formats)
@@ -277,13 +276,13 @@ module ActionView #:nodoc:
@config = nil
@formats = formats
@assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) }
- @controller = controller
+ @_controller = controller
@helpers = self.class.helpers || Module.new
@_content_for = Hash.new {|h,k| h[k] = ActionView::SafeBuffer.new }
self.view_paths = view_paths
end
- attr_internal :template
+ attr_internal :controller, :template
attr_reader :view_paths
def view_paths=(paths)
@@ -298,12 +297,11 @@ module ActionView #:nodoc:
# Evaluates the local assigns and controller ivars, pushes them to the view.
def _evaluate_assigns_and_ivars #:nodoc:
- if @controller
- variables = @controller.instance_variable_names
- variables -= @controller.protected_instance_variables if @controller.respond_to?(:protected_instance_variables)
- variables.each { |name| instance_variable_set(name, @controller.instance_variable_get(name)) }
+ if controller
+ variables = controller.instance_variable_names
+ variables -= controller.protected_instance_variables if controller.respond_to?(:protected_instance_variables)
+ variables.each { |name| instance_variable_set(name, controller.instance_variable_get(name)) }
end
end
-
end
end
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 15b70ecff5..83357dd76f 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -634,8 +634,8 @@ module ActionView
# Prefix with <tt>/dir/</tt> if lacking a leading +/+. Account for relative URL
# roots. Rewrite the asset path for cache-busting asset ids. Include
# asset host, if configured, with the correct request protocol.
- def compute_public_path(source, dir, ext = nil, include_host = true)
- has_request = @controller.respond_to?(:request)
+ def compute_public_path(source, dir, ext = nil, include_host = true)
+ has_request = controller.respond_to?(:request)
source_ext = File.extname(source)[1..-1]
if ext && !is_uri?(source) && (source_ext.blank? || (ext != source_ext && File.exist?(File.join(config.assets_dir, dir, "#{source}.#{ext}"))))
@@ -658,7 +658,7 @@ module ActionView
host = compute_asset_host(source)
if has_request && !host.blank? && !is_uri?(host)
- host = "#{@controller.request.protocol}#{host}"
+ host = "#{controller.request.protocol}#{host}"
end
"#{host}#{source}"
@@ -681,7 +681,7 @@ module ActionView
if host.is_a?(Proc) || host.respond_to?(:call)
case host.is_a?(Proc) ? host.arity : host.method(:call).arity
when 2
- request = @controller.respond_to?(:request) && @controller.request
+ request = controller.respond_to?(:request) && controller.request
host.call(source, request)
else
host.call(source)
diff --git a/actionpack/lib/action_view/helpers/cache_helper.rb b/actionpack/lib/action_view/helpers/cache_helper.rb
index 64d1ad2715..d5cc14b29a 100644
--- a/actionpack/lib/action_view/helpers/cache_helper.rb
+++ b/actionpack/lib/action_view/helpers/cache_helper.rb
@@ -32,7 +32,7 @@ module ActionView
# <i>Topics listed alphabetically</i>
# <% end %>
def cache(name = {}, options = nil, &block)
- @controller.fragment_for(output_buffer, name, options, &block)
+ controller.fragment_for(output_buffer, name, options, &block)
end
end
end
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 14628c5404..511386fede 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -13,7 +13,7 @@ module ActionView
# Need to map default url options to controller one.
def default_url_options(*args) #:nodoc:
- @controller.send(:default_url_options, *args)
+ controller.send(:default_url_options, *args)
end
# Returns the URL for the set of +options+ provided. This takes the
@@ -89,10 +89,10 @@ module ActionView
when Hash
options = { :only_path => options[:host].nil? }.update(options.symbolize_keys)
escape = options.key?(:escape) ? options.delete(:escape) : false
- @controller.send(:url_for, options)
+ controller.send(:url_for, options)
when :back
escape = false
- @controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
+ controller.request.env["HTTP_REFERER"] || 'javascript:history.back()'
else
escape = false
polymorphic_path(options)
@@ -546,10 +546,10 @@ module ActionView
# # => false
def current_page?(options)
url_string = CGI.unescapeHTML(url_for(options))
- request = @controller.request
- # We ignore any extra parameters in the request_uri if the
+ request = controller.request
+ # We ignore any extra parameters in the request_uri if the
# submitted url doesn't have any either. This lets the function
- # work with things like ?order=asc
+ # work with things like ?order=asc
if url_string.index("?")
request_uri = request.request_uri
else