Skip to content

Commit

Permalink
Refactor active_link_to method
Browse files Browse the repository at this point in the history
This is  just a simple suggested refactor to DRY the method up a bit.
  • Loading branch information
Roberto Pando authored Apr 7, 2017
1 parent 57e6cfa commit 7a80470
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/active_link_to/active_link_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ module ActiveLinkTo
# active_link_to('/users', class_active: 'enabled')
# active_link_to(users_path, active: :exclusive, wrap_tag: :li)
def active_link_to(*args, &block)
if block_given?
name = capture(&block)
options = args[0] || {}
html_options = args[1] || {}
else
name = args[0]
options = args[1] || {}
html_options = args[2] || {}
end
name = block_given? ? capture(&block) : args.shift
options = args.shift || {}
html_options = args.shift || {}

url = url_for(options)

active_options = { }
Expand Down

0 comments on commit 7a80470

Please sign in to comment.