Skip to content

Commit

Permalink
Merge pull request #21894 from abhishekjain16/refactor_with_dry
Browse files Browse the repository at this point in the history
Follow DRY principle and remove duplication
  • Loading branch information
rafaelfranca committed Oct 8, 2015
2 parents 0d4aa37 + 9a57e7f commit a7bd1c7
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions actionview/lib/action_view/routing_url_for.rb
Expand Up @@ -84,21 +84,13 @@ def url_for(options = nil)
when Hash
options = options.symbolize_keys
unless options.key?(:only_path)
if options[:host].nil?
options[:only_path] = _generate_paths_by_default
else
options[:only_path] = false
end
options[:only_path] = only_path?(options[:host])
end

super(options)
when ActionController::Parameters
unless options.key?(:only_path)
if options[:host].nil?
options[:only_path] = _generate_paths_by_default
else
options[:only_path] = false
end
options[:only_path] = only_path?(options[:host])
end

super(options)
Expand Down Expand Up @@ -147,5 +139,9 @@ def optimize_routes_generation? #:nodoc:
def _generate_paths_by_default
true
end

def only_path?(host)
_generate_paths_by_default unless host
end
end
end

0 comments on commit a7bd1c7

Please sign in to comment.