Class: Woody::Decorators::User
- Inherits:
-
Base
- Object
- Base
- Woody::Decorators::User
show all
- Defined in:
- lib/woody/decorators/user.rb
Instance Method Summary
collapse
Methods inherited from Base
#method_missing
Constructor Details
#initialize(model, config) ⇒ User
Returns a new instance of User.
6
7
8
9
|
# File 'lib/woody/decorators/user.rb', line 6
def initialize(model, config)
@config = OpenStruct.new(config)
super(model)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Woody::Decorators::Base
Instance Method Details
#avatar(platform) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/woody/decorators/user.rb', line 11
def avatar(platform)
invalid_platform(platform) unless %w(creator brands).include?(platform)
return user_avatar(platform: platform) if platform == 'brands'
@model.onboarded ? user_avatar(platform: platform, cache_bust: true)
: default_avatar(platform)
end
|
#exist? ⇒ Boolean
18
19
20
|
# File 'lib/woody/decorators/user.rb', line 18
def exist?
!@model.nil?
end
|
#first_name ⇒ Object
22
23
24
|
# File 'lib/woody/decorators/user.rb', line 22
def first_name
@model.first_name.capitalize
end
|
#full_name(truncate: false, size: 14) ⇒ Object
26
27
28
29
30
|
# File 'lib/woody/decorators/user.rb', line 26
def full_name(truncate: false, size: 14)
output = [first_name, last_name].join(' ')
return output unless output.length >= size && truncate
format('%s...', output[0..(size - 1)])
end
|
#id ⇒ Object
39
40
41
|
# File 'lib/woody/decorators/user.rb', line 39
def id
@model.auth0_id
end
|
#last_name ⇒ Object
43
44
45
|
# File 'lib/woody/decorators/user.rb', line 43
def last_name
@model.last_name.capitalize
end
|
#short_name ⇒ Object
32
33
34
35
36
37
|
# File 'lib/woody/decorators/user.rb', line 32
def short_name
[
first_name,
last_name[0]
].join(' ')
end
|