Class: Integral::UserDecorator

Inherits:
BaseDecorator show all
Defined in:
app/decorators/integral/user_decorator.rb

Overview

User view-level logic

Instance Method Summary collapse

Methods inherited from BaseDecorator

#activity_url, #backend_url, #edit_backend_url, #render_active_block_list, #to_backend_card

Instance Method Details

#avatar_circleObject



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. :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. :div, class: "avatar-circle avatar-circle-bg-#{initials.first.to_s.downcase.ord % 10}" do
      h. :div, initials, class: 'avatar-text'
    end
  end
end

#avatar_urlObject



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

#titleString

Returns formatted title.

Returns:

  • (String)

    formatted title



5
6
7
# File 'app/decorators/integral/user_decorator.rb', line 5

def title
  object.name
end