Skip to content

Commit

Permalink
Performance: refactor convert_options_to_data_attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkone committed Sep 27, 2010
1 parent dcabc6c commit b127e0c
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions actionpack/lib/action_view/helpers/url_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -584,20 +584,24 @@ def current_page?(options)


private private
def convert_options_to_data_attributes(options, html_options) def convert_options_to_data_attributes(options, html_options)
html_options = {} if html_options.nil? if html_options.nil?
html_options = html_options.stringify_keys link_to_remote_options?(options) ? {'data-remote' => 'true'} : {}
else
html_options = html_options.stringify_keys
html_options['data-remote'] = 'true' if link_to_remote_options?(options) || link_to_remote_options?(html_options)


if (options.is_a?(Hash) && options.key?('remote') && options.delete('remote')) || (html_options.is_a?(Hash) && html_options.key?('remote') && html_options.delete('remote')) confirm = html_options.delete('confirm')
html_options['data-remote'] = 'true' method = html_options.delete('method')
end


add_confirm_to_attributes!(html_options, confirm) if confirm
add_method_to_attributes!(html_options, method) if method


confirm = html_options.delete('confirm') html_options
method = html_options.delete('method') end
add_confirm_to_attributes!(html_options, confirm) if confirm end
add_method_to_attributes!(html_options, method) if method


html_options def link_to_remote_options?(options)
options.is_a?(Hash) && options.key?('remote') && options.delete('remote')
end end


def add_confirm_to_attributes!(html_options, confirm) def add_confirm_to_attributes!(html_options, confirm)
Expand Down

0 comments on commit b127e0c

Please sign in to comment.