Class: MultiAuthSample::User
- Defined in:
- lib/multi_auth_sample/models/user.rb
Overview
User Model.
Instance Attribute Summary collapse
-
#created_at ⇒ String
TODO: Write general description for this method.
-
#email ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#updated_at ⇒ 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(id = SKIP, name = SKIP, email = SKIP, created_at = SKIP, updated_at = SKIP, additional_properties = {}) ⇒ User
constructor
A new instance of User.
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, name = SKIP, email = SKIP, created_at = SKIP, updated_at = SKIP, additional_properties = {}) ⇒ User
Returns a new instance of User.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/multi_auth_sample/models/user.rb', line 59 def initialize(id = SKIP, name = SKIP, email = SKIP, created_at = SKIP, updated_at = SKIP, additional_properties = {}) @id = id unless id == SKIP @name = name unless name == SKIP @email = email unless email == SKIP @created_at = created_at unless created_at == SKIP @updated_at = updated_at unless updated_at == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#created_at ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/multi_auth_sample/models/user.rb', line 26 def created_at @created_at end |
#email ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/multi_auth_sample/models/user.rb', line 22 def email @email end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/multi_auth_sample/models/user.rb', line 14 def id @id end |
#name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/multi_auth_sample/models/user.rb', line 18 def name @name end |
#updated_at ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/multi_auth_sample/models/user.rb', line 30 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/multi_auth_sample/models/user.rb', line 78 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP email = hash.key?('email') ? hash['email'] : SKIP created_at = hash.key?('created_at') ? hash['created_at'] : SKIP updated_at = hash.key?('updated_at') ? hash['updated_at'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. User.new(id, name, email, created_at, updated_at, hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/multi_auth_sample/models/user.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['email'] = 'email' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/multi_auth_sample/models/user.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 51 52 |
# File 'lib/multi_auth_sample/models/user.rb', line 44 def self.optionals %w[ id name email created_at updated_at ] end |