Class: User
- Inherits:
-
Object
- Object
- User
- Defined in:
- lib/domain/user.rb
Overview
User model conatining user create and update attributes
Instance Attribute Summary collapse
-
#current_password ⇒ Object
Returns the value of attribute current_password.
-
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
-
#email ⇒ Object
Returns the value of attribute email.
-
#first_name ⇒ Object
Returns the value of attribute first_name.
-
#image_url ⇒ Object
Returns the value of attribute image_url.
-
#last_name ⇒ Object
Returns the value of attribute last_name.
-
#new_password ⇒ Object
Returns the value of attribute new_password.
-
#password ⇒ Object
Returns the value of attribute password.
Class Method Summary collapse
-
.get_payload(user) ⇒ Json
Gets Json represenatation of user object.
Instance Method Summary collapse
-
#initialize(first_name: nil, last_name: nil, password: nil, current_password: nil, new_password: nil, date_of_birth: nil, email: nil, image_url: nil) ⇒ User
constructor
Inialise the User model.
-
#to_json(*data) ⇒ Json
Converts User object to Json object.
Constructor Details
#initialize(first_name: nil, last_name: nil, password: nil, current_password: nil, new_password: nil, date_of_birth: nil, email: nil, image_url: nil) ⇒ User
Inialise the User model
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/domain/user.rb', line 28 def initialize(first_name: nil, last_name: nil, password: nil, current_password: nil, new_password: nil, date_of_birth: nil, email: nil, image_url: nil) self.first_name = first_name self.last_name = last_name self.password = password self.current_password = current_password self.new_password = new_password self.date_of_birth = date_of_birth self.email = email self.image_url = image_url end |
Instance Attribute Details
#current_password ⇒ Object
Returns the value of attribute current_password.
10 11 12 |
# File 'lib/domain/user.rb', line 10 def current_password @current_password end |
#date_of_birth ⇒ Object
Returns the value of attribute date_of_birth.
12 13 14 |
# File 'lib/domain/user.rb', line 12 def date_of_birth @date_of_birth end |
#email ⇒ Object
Returns the value of attribute email.
13 14 15 |
# File 'lib/domain/user.rb', line 13 def email @email end |
#first_name ⇒ Object
Returns the value of attribute first_name.
7 8 9 |
# File 'lib/domain/user.rb', line 7 def first_name @first_name end |
#image_url ⇒ Object
Returns the value of attribute image_url.
14 15 16 |
# File 'lib/domain/user.rb', line 14 def image_url @image_url end |
#last_name ⇒ Object
Returns the value of attribute last_name.
8 9 10 |
# File 'lib/domain/user.rb', line 8 def last_name @last_name end |
#new_password ⇒ Object
Returns the value of attribute new_password.
11 12 13 |
# File 'lib/domain/user.rb', line 11 def new_password @new_password end |
#password ⇒ Object
Returns the value of attribute password.
9 10 11 |
# File 'lib/domain/user.rb', line 9 def password @password end |
Class Method Details
.get_payload(user) ⇒ Json
Gets Json represenatation of user object
70 71 72 |
# File 'lib/domain/user.rb', line 70 def self.get_payload(user) user.to_json end |
Instance Method Details
#to_json(*data) ⇒ Json
Converts User object to Json object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/domain/user.rb', line 48 def to_json(*data) hash = { first_name: @first_name, last_name: @last_name, password: @password, current_password: @current_password, new_password: @new_password, date_of_birth: @date_of_birth, email: @email, image_url: @image_url } hash.delete_if { |k, v| v.nil? } hash.to_json(*data) end |