Class: UserDecorator

Inherits:
Draper::Decorator
  • Object
show all
Includes:
Draper::LazyHelpers
Defined in:
app/decorators/user_decorator.rb

Instance Method Summary collapse

Instance Method Details

#display_creditsObject



27
28
29
# File 'app/decorators/user_decorator.rb', line 27

def display_credits
  number_to_currency source.credits
end

#display_imageObject



9
10
11
# File 'app/decorators/user_decorator.rb', line 9

def display_image
  source.uploaded_image.thumb_avatar.url || source.image_url || source.gravatar_url || '/assets/user.png'
end

#display_image_html(options = {width: 119, height: 121}) ⇒ Object



13
14
15
16
17
# File 'app/decorators/user_decorator.rb', line 13

def display_image_html options={width: 119, height: 121}
  (%{<div class="avatar_wrapper" style="width: #{options[:width]}px; height: #{options[:height]}px">} +
    h.image_tag(display_image, alt: "User", style: "width: #{options[:width]}px; height: auto") +
    %{</div>}).html_safe
end

#display_nameObject



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

def display_name
  source.name || source.full_name || I18n.t('user.no_name')
end

#display_total_of_backsObject



31
32
33
# File 'app/decorators/user_decorator.rb', line 31

def display_total_of_backs
  number_to_currency source.backs.confirmed.sum(:value)
end

#medium_nameObject



23
24
25
# File 'app/decorators/user_decorator.rb', line 23

def medium_name
  truncate display_name, length: 42
end

#short_nameObject



19
20
21
# File 'app/decorators/user_decorator.rb', line 19

def short_name
  truncate display_name, length: 20
end