Commit 996f8154 authored by Andreas Brandl's avatar Andreas Brandl

Extract method to improve readability.

parent 217df548
...@@ -8,18 +8,22 @@ module AvatarsHelper ...@@ -8,18 +8,22 @@ module AvatarsHelper
})) }))
end end
def user_avatar_without_link(options = {}) def user_avatar_url_for(options = {})
avatar_size = options[:size] || 16 if options[:url]
user_name = options[:user].try(:name) || options[:user_name]
avatar_url = if options[:url]
options[:url] options[:url]
elsif options[:user] elsif options[:user]
avatar_icon_for_user(options[:user], avatar_size) avatar_icon_for_user(options[:user], options[:size])
else else
avatar_icon_for_email(options[:user_email], avatar_size) avatar_icon_for_email(options[:user_email], options[:size])
end
end end
def user_avatar_without_link(options = {})
avatar_size = options[:size] || 16
user_name = options[:user].try(:name) || options[:user_name]
avatar_url = user_avatar_url_for(options.merge(size: avatar_size))
has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip] has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip]
data_attributes = options[:data] || {} data_attributes = options[:data] || {}
css_class = %W[avatar s#{avatar_size}].push(*options[:css_class]) css_class = %W[avatar s#{avatar_size}].push(*options[:css_class])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment