From 8b1ccd5949395530296daf3c0d620a8106e9ac4b Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 4 Mar 2014 08:21:32 -0300 Subject: Simplify handling of defaults/options in button_tag There's no need to rely on Active Support's Hash#reverse_merge for simple cases with default values, since we can just merge from the default rather than reverse merge from the options. This also avoids the creation of one extra hash object by moving to a Hash#merge! call. --- actionview/lib/action_view/helpers/form_tag_helper.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'actionview') diff --git a/actionview/lib/action_view/helpers/form_tag_helper.rb b/actionview/lib/action_view/helpers/form_tag_helper.rb index 961d01eff4..326e303971 100644 --- a/actionview/lib/action_view/helpers/form_tag_helper.rb +++ b/actionview/lib/action_view/helpers/form_tag_helper.rb @@ -469,16 +469,13 @@ module ActionView # # => # def button_tag(content_or_options = nil, options = nil, &block) - default_options = { 'name' => 'button', 'type' => 'submit' } - if content_or_options.is_a? Hash options = content_or_options else options ||= {} end - options = options.stringify_keys - options = options.reverse_merge default_options + options = { 'name' => 'button', 'type' => 'submit' }.merge!(options.stringify_keys) if block_given? content_tag :button, options, &block -- cgit v1.2.3