class User
User
model conatining user create and update attributes
Attributes
current_password[RW]
date_of_birth[RW]
email[RW]
first_name[RW]
image_url[RW]
last_name[RW]
new_password[RW]
password[RW]
Public Class Methods
get_payload(user)
click to toggle source
Gets Json represenatation of user object
@param [Object] user User
object
@return [Json] Json represenatation of user object
# File lib/domain/user.rb, line 73 def self.get_payload(user) user.as_json.to_json end
get_payload_with_client_info(user)
click to toggle source
Gets Json represenatation of user object with client details
@param [Object] user User
object
@return [Json] Json represenatation of user object
# File lib/domain/user.rb, line 84 def self.get_payload_with_client_info(user) user.as_json.merge!({ 'client_id' => ApplicationConfig.client_id, 'client_secret' => ApplicationConfig.client_secret }).to_json end
new(first_name: nil, last_name: nil, password: nil, current_password: nil, new_password: nil, date_of_birth: nil, email: nil, image_url: nil)
click to toggle source
Inialise the User
model
@param [String] first_name
@param [String] last_name
@param [String] password @param [String] current_password
@param [String] new_password
@param [String] date_of_birth
@param [String] email @param [String] image_url
# 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
Public Instance Methods
as_json(options = {})
click to toggle source
Converts User
object to Hash and deletes null value fields
@param [Refrence] options
@return [Hash] Hash of user object
# File lib/domain/user.rb, line 48 def as_json(options = {}) hash_data = { self.class.name.downcase => { 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_data.each { |k, v| v.delete_if { |k, v| v.nil? } } hash_data end