aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2007-07-24 16:48:57 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2007-07-24 16:48:57 +0000
commitedd68a587f412ccdf15613c663acbab341d45017 (patch)
tree386437d0bb09c7944943b0590a5f80c60146e853 /actionpack/lib/action_view/helpers
parent34b081112536e382845e8dee146d884b4af20c4a (diff)
downloadrails-edd68a587f412ccdf15613c663acbab341d45017.tar.gz
rails-edd68a587f412ccdf15613c663acbab341d45017.tar.bz2
rails-edd68a587f412ccdf15613c663acbab341d45017.zip
Refactored in use of extract_options! (closes #9079) [josh]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7220 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/javascript_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/prototype_helper.rb2
5 files changed, 8 insertions, 8 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index 97ddc41c7e..08abdbd8a8 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -118,7 +118,7 @@ module ActionView
# you need is significantly different from the default presentation, it makes plenty of sense to access the object.errors
# instance yourself and set it up. View the source of this method to see how easy it is.
def error_messages_for(*params)
- options = params.last.is_a?(Hash) ? params.pop.symbolize_keys : {}
+ options = params.extract_options!.symbolize_keys
objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact
count = objects.inject(0) {|sum, object| sum + object.errors.count }
unless count.zero?
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
index 6c4eb0931c..46b08fce76 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -172,7 +172,7 @@ module ActionView
# javascript_include_tag "prototype", "cart", "checkout", :cache => "shop" # when ActionController::Base.perform_caching is false =>
# <script type="text/javascript" src="/javascripts/shop.js"></script>
def javascript_include_tag(*sources)
- options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
+ options = sources.extract_options!.stringify_keys
cache = options.delete("cache")
if ActionController::Base.perform_caching && cache
@@ -281,7 +281,7 @@ module ActionView
# stylesheet_link_tag "shop", "cart", "checkout", :cache => "payment" # when ActionController::Base.perform_caching is true =>
# <link href="/stylesheets/payment.css" media="screen" rel="Stylesheet" type="text/css" />
def stylesheet_link_tag(*sources)
- options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { }
+ options = sources.extract_options!.stringify_keys
cache = options.delete("cache")
if ActionController::Base.perform_caching && cache
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 22d2984adb..9c31fb6c90 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -158,7 +158,7 @@ module ActionView
def form_for(record_or_name_or_array, *args, &proc)
raise ArgumentError, "Missing block" unless block_given?
- options = args.last.is_a?(Hash) ? args.pop : {}
+ options = args.extract_options!
case record_or_name_or_array
when String, Symbol
@@ -212,7 +212,7 @@ module ActionView
# like FormOptionHelper#collection_select and DateHelper#datetime_select.
def fields_for(object_name, *args, &block)
raise ArgumentError, "Missing block" unless block_given?
- options = args.last.is_a?(Hash) ? args.pop : {}
+ options = args.extract_options!
object = args.first
builder = options[:builder] || ActionView::Base.default_form_builder
diff --git a/actionpack/lib/action_view/helpers/javascript_helper.rb b/actionpack/lib/action_view/helpers/javascript_helper.rb
index 4dd7854367..51cbfb95d9 100644
--- a/actionpack/lib/action_view/helpers/javascript_helper.rb
+++ b/actionpack/lib/action_view/helpers/javascript_helper.rb
@@ -80,7 +80,7 @@ module ActionView
# return false;">Show me more</a>
#
def link_to_function(name, *args, &block)
- html_options = args.last.is_a?(Hash) ? args.pop : {}
+ html_options = args.extract_options!
function = args[0] || ''
html_options.symbolize_keys!
@@ -111,7 +111,7 @@ module ActionView
# page[:details].visual_effect :toggle_slide
# end
def button_to_function(name, *args, &block)
- html_options = args.last.is_a?(Hash) ? args.pop : {}
+ html_options = args.extract_options!
function = args[0] || ''
html_options.symbolize_keys!
diff --git a/actionpack/lib/action_view/helpers/prototype_helper.rb b/actionpack/lib/action_view/helpers/prototype_helper.rb
index d1f992486f..0da5cc5579 100644
--- a/actionpack/lib/action_view/helpers/prototype_helper.rb
+++ b/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -182,7 +182,7 @@ module ActionView
# Works like form_remote_tag, but uses form_for semantics.
def remote_form_for(record_or_name, *args, &proc)
- options = args.last.is_a?(Hash) ? args.pop : {}
+ options = args.extract_options!
case record_or_name
when String, Symbol