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
|
# File 'lib/woody/decorators/user.rb', line 11
def avatar(platform)
invalid_platform(platform) unless %w(creator brands).include?(platform)
return user_avatar(platform) if platform == 'brands'
@model.onboarded ? user_avatar(platform) : default_avatar(platform)
end
|
#exist? ⇒ Boolean
17
18
19
|
# File 'lib/woody/decorators/user.rb', line 17
def exist?
!@model.nil?
end
|
#first_name ⇒ Object
21
22
23
|
# File 'lib/woody/decorators/user.rb', line 21
def first_name
@model.first_name.capitalize
end
|
#full_name ⇒ Object
25
26
27
|
# File 'lib/woody/decorators/user.rb', line 25
def full_name
[first_name, last_name].join(' ')
end
|
#id ⇒ Object
29
30
31
|
# File 'lib/woody/decorators/user.rb', line 29
def id
@model.auth0_id
end
|
#last_name ⇒ Object
33
34
35
|
# File 'lib/woody/decorators/user.rb', line 33
def last_name
@model.last_name.capitalize
end
|