This shouldn't impact the implementation, it could be literally anything (helper method, object method, local variable or anything).
The specification would be { classname: true/false }.
link_to user.name, user_path(user), class: { btn: true, active: user.active? } // => object method call link_to user.name, user_path(user), class: { btn: true, active: active_user?(user) } // => helper method call link_to user.name, user_path(user), class: { btn: true, active: active } // => local variable call
Also, the link_to can be in the view or in a helper method.
If you want to see this working, you can implement a prototype on application helper like this (untested and not fully compatible with current link_to implementation (need to accepts blocks, string keys, etc)):
module ApplicationHelper
def link_to(content, path, options = {})
klass = if Hash === options[:class]
parse_class_hash(options[:class])
else
options[:class]
end
super(content, path, options.merge(class: klass))
end
def parse_class_hash(classes)
string = []
classes.each_pair do |name, value|
string << name if value
end
string.join(' ')
end
end