Class: CtdDocumentation::User
- Defined in:
- lib/ctd_documentation/models/user.rb
Overview
User Model.
Instance Attribute Summary collapse
-
#first_name ⇒ String
TODO: Write general description for this method.
-
#last_name ⇒ String
TODO: Write general description for this method.
-
#mail ⇒ String
TODO: Write general description for this method.
-
#password ⇒ String
TODO: Write general description for this method.
-
#username ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(username = nil, password = nil, first_name = SKIP, last_name = SKIP, mail = SKIP) ⇒ User
constructor
A new instance of User.
Methods inherited from BaseModel
Constructor Details
#initialize(username = nil, password = nil, first_name = SKIP, last_name = SKIP, mail = SKIP) ⇒ User
Returns a new instance of User.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ctd_documentation/models/user.rb', line 57 def initialize(username = nil, password = nil, first_name = SKIP, last_name = SKIP, mail = SKIP) @username = username @password = password @first_name = first_name unless first_name == SKIP @last_name = last_name unless last_name == SKIP @mail = mail unless mail == SKIP end |
Instance Attribute Details
#first_name ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/ctd_documentation/models/user.rb', line 22 def first_name @first_name end |
#last_name ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/ctd_documentation/models/user.rb', line 26 def last_name @last_name end |
#mail ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/ctd_documentation/models/user.rb', line 30 def mail @mail end |
#password ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/ctd_documentation/models/user.rb', line 18 def password @password end |
#username ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/ctd_documentation/models/user.rb', line 14 def username @username end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ctd_documentation/models/user.rb', line 70 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. username = hash.key?('username') ? hash['username'] : nil password = hash.key?('password') ? hash['password'] : nil first_name = hash.key?('first_name') ? hash['first_name'] : SKIP last_name = hash.key?('last_name') ? hash['last_name'] : SKIP mail = hash.key?('mail') ? hash['mail'] : SKIP # Create object from extracted values. User.new(username, password, first_name, last_name, mail) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/ctd_documentation/models/user.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['username'] = 'username' @_hash['password'] = 'password' @_hash['first_name'] = 'first_name' @_hash['last_name'] = 'last_name' @_hash['mail'] = 'mail' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/ctd_documentation/models/user.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 |
# File 'lib/ctd_documentation/models/user.rb', line 44 def self.optionals %w[ first_name last_name mail ] end |