aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-03-13 02:14:31 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-03-13 02:14:31 +0000
commit07d8f46b85b08187cabd477cc3ca37f2c818e9aa (patch)
tree56e151cd3fbd57e6d86e2ff19efe4b429874c0ab /actionpack
parent93db1989fe1146ea79e3b0b2252542408ff86443 (diff)
downloadrails-07d8f46b85b08187cabd477cc3ca37f2c818e9aa.tar.gz
rails-07d8f46b85b08187cabd477cc3ca37f2c818e9aa.tar.bz2
rails-07d8f46b85b08187cabd477cc3ca37f2c818e9aa.zip
Consistent public/protected/private visibility for chained methods. Closes #7813.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6396 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/benchmarking.rb60
-rw-r--r--actionpack/lib/action_controller/filters.rb20
-rw-r--r--actionpack/lib/action_controller/flash.rb32
-rw-r--r--actionpack/lib/action_controller/layout.rb39
5 files changed, 80 insertions, 73 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 669732a148..2ea1b4da27 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Consistent public/protected/private visibility for chained methods. #7813 [dcmanges]
+
* Prefer MIME constants to strings. #7707 [Dan Kubb]
* Allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan]
diff --git a/actionpack/lib/action_controller/benchmarking.rb b/actionpack/lib/action_controller/benchmarking.rb
index 469976e532..8e0d83c2d6 100644
--- a/actionpack/lib/action_controller/benchmarking.rb
+++ b/actionpack/lib/action_controller/benchmarking.rb
@@ -40,44 +40,44 @@ module ActionController #:nodoc:
end
end
- def render_with_benchmark(options = nil, deprecated_status = nil, &block)
- unless logger
- render_without_benchmark(options, deprecated_status, &block)
- else
- db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+ protected
+ def render_with_benchmark(options = nil, deprecated_status = nil, &block)
+ unless logger
+ render_without_benchmark(options, deprecated_status, &block)
+ else
+ db_runtime = ActiveRecord::Base.connection.reset_runtime if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
- render_output = nil
- @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, deprecated_status, &block) }.real
+ render_output = nil
+ @rendering_runtime = Benchmark::measure{ render_output = render_without_benchmark(options, deprecated_status, &block) }.real
- if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
- @db_rt_before_render = db_runtime
- @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
- @rendering_runtime -= @db_rt_after_render
- end
+ if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+ @db_rt_before_render = db_runtime
+ @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime
+ @rendering_runtime -= @db_rt_after_render
+ end
- render_output
- end
- end
+ render_output
+ end
+ end
- def perform_action_with_benchmark
- unless logger
- perform_action_without_benchmark
- else
- runtime = [ Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001 ].max
+ private
+ def perform_action_with_benchmark
+ unless logger
+ perform_action_without_benchmark
+ else
+ runtime = [ Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001 ].max
- log_message = "Completed in #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)"
- log_message << rendering_runtime(runtime) if defined?(@rendering_runtime)
- log_message << active_record_runtime(runtime) if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
- log_message << " | #{headers["Status"]}"
- log_message << " [#{complete_request_uri rescue "unknown"}]"
+ log_message = "Completed in #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)"
+ log_message << rendering_runtime(runtime) if defined?(@rendering_runtime)
+ log_message << active_record_runtime(runtime) if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected?
+ log_message << " | #{headers["Status"]}"
+ log_message << " [#{complete_request_uri rescue "unknown"}]"
- logger.info(log_message)
- response.headers["X-Runtime"] = sprintf("%.5f", runtime)
+ logger.info(log_message)
+ response.headers["X-Runtime"] = sprintf("%.5f", runtime)
+ end
end
- end
-
- private
def rendering_runtime(runtime)
" | Rendering: #{sprintf("%.5f", @rendering_runtime)} (#{sprintf("%d", (@rendering_runtime * 100) / runtime)}%)"
end
diff --git a/actionpack/lib/action_controller/filters.rb b/actionpack/lib/action_controller/filters.rb
index 3290defff8..ec5bb759df 100644
--- a/actionpack/lib/action_controller/filters.rb
+++ b/actionpack/lib/action_controller/filters.rb
@@ -615,15 +615,6 @@ module ActionController #:nodoc:
end
end
- def perform_action_with_filters
- call_filter(self.class.filter_chain, 0)
- end
-
- def process_with_filters(request, response, method = :perform_action, *arguments) #:nodoc:
- @before_filter_chain_aborted = false
- process_without_filters(request, response, method, *arguments)
- end
-
def filter_chain
self.class.filter_chain
end
@@ -654,7 +645,18 @@ module ActionController #:nodoc:
return false
end
+ protected
+
+ def process_with_filters(request, response, method = :perform_action, *arguments) #:nodoc:
+ @before_filter_chain_aborted = false
+ process_without_filters(request, response, method, *arguments)
+ end
+
private
+ def perform_action_with_filters
+ call_filter(self.class.filter_chain, 0)
+ end
+
def process_cleanup_with_filters
if @before_filter_chain_aborted
close_session
diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb
index 0d12503904..2544db2fda 100644
--- a/actionpack/lib/action_controller/flash.rb
+++ b/actionpack/lib/action_controller/flash.rb
@@ -136,23 +136,14 @@ module ActionController #:nodoc:
end
module InstanceMethods #:nodoc:
- def assign_shortcuts_with_flash(request, response) #:nodoc:
- assign_shortcuts_without_flash(request, response)
- flash(:refresh)
- end
-
- def process_cleanup_with_flash
- flash.sweep if @_session
- process_cleanup_without_flash
- end
- def reset_session_with_flash
- reset_session_without_flash
- remove_instance_variable(:@_flash)
- flash(:refresh)
- end
+ protected
+ def reset_session_with_flash
+ reset_session_without_flash
+ remove_instance_variable(:@_flash)
+ flash(:refresh)
+ end
- protected
# 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.
# Note that if sessions are disabled only flash.now will work.
@@ -177,6 +168,17 @@ module ActionController #:nodoc:
ActiveSupport::Deprecation.warn 'keep_flash is deprecated; use flash.keep instead.', caller
flash.keep
end
+
+ private
+ def assign_shortcuts_with_flash(request, response) #:nodoc:
+ assign_shortcuts_without_flash(request, response)
+ flash(:refresh)
+ end
+
+ def process_cleanup_with_flash
+ flash.sweep if @_session
+ process_cleanup_without_flash
+ end
end
end
end
diff --git a/actionpack/lib/action_controller/layout.rb b/actionpack/lib/action_controller/layout.rb
index 115fd7ac18..ca070d0577 100644
--- a/actionpack/lib/action_controller/layout.rb
+++ b/actionpack/lib/action_controller/layout.rb
@@ -233,31 +233,32 @@ module ActionController #:nodoc:
end
end
- def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layout = nil, &block) #:nodoc:
- template_with_options = options.is_a?(Hash)
+ protected
+ def render_with_a_layout(options = nil, deprecated_status = nil, deprecated_layout = nil, &block) #:nodoc:
+ template_with_options = options.is_a?(Hash)
- if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout))
- assert_existence_of_template_file(layout)
+ if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options, deprecated_layout))
+ assert_existence_of_template_file(layout)
- options = options.merge :layout => false if template_with_options
- logger.info("Rendering template within #{layout}") if logger
+ options = options.merge :layout => false if template_with_options
+ logger.info("Rendering template within #{layout}") if logger
- if template_with_options
- content_for_layout = render_with_no_layout(options, &block)
- deprecated_status = options[:status] || deprecated_status
+ if template_with_options
+ content_for_layout = render_with_no_layout(options, &block)
+ deprecated_status = options[:status] || deprecated_status
+ else
+ content_for_layout = render_with_no_layout(options, deprecated_status, &block)
+ end
+
+ erase_render_results
+ add_variables_to_assigns
+ @template.instance_variable_set("@content_for_layout", content_for_layout)
+ response.layout = layout
+ render_text(@template.render_file(layout, true), deprecated_status)
else
- content_for_layout = render_with_no_layout(options, deprecated_status, &block)
+ render_with_no_layout(options, deprecated_status, &block)
end
-
- erase_render_results
- add_variables_to_assigns
- @template.instance_variable_set("@content_for_layout", content_for_layout)
- response.layout = layout
- render_text(@template.render_file(layout, true), deprecated_status)
- else
- render_with_no_layout(options, deprecated_status, &block)
end
- end
private