Class: Integral::UserDecorator
- Inherits:
-
BaseDecorator
- Object
- Draper::Decorator
- BaseDecorator
- Integral::UserDecorator
- Defined in:
- app/decorators/integral/user_decorator.rb
Overview
User view-level logic
Instance Method Summary collapse
- #avatar_circle ⇒ Object
- #avatar_url ⇒ Object
-
#title ⇒ String
Formatted title.
Methods inherited from BaseDecorator
#activity_url, #backend_url, #edit_backend_url, #render_active_block_list, #to_backend_card
Instance Method Details
#avatar_circle ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/decorators/integral/user_decorator.rb', line 17 def avatar_circle if object.avatar.attached? h.content_tag :div, class: "avatar-circle" do h.image_tag(avatar_url, alt: object.name) end else initials = object.name.split(' ').map { |name| name[0] }.join[0..1] h.content_tag :div, class: "avatar-circle avatar-circle-bg-#{initials.first.to_s.downcase.ord % 10}" do h.content_tag :div, initials, class: 'avatar-text' end end end |
#avatar_url ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/decorators/integral/user_decorator.rb', line 9 def avatar_url if object.avatar.attached? app_url_helpers.url_for(object.avatar) else ActionController::Base.helpers.asset_path('integral/defaults/user_avatar.jpg') end end |
#title ⇒ String
Returns formatted title.
5 6 7 |
# File 'app/decorators/integral/user_decorator.rb', line 5 def title object.name end |