Class: TestApi::UsersRequest
- Defined in:
- lib/test_api/models/users_request.rb
Overview
UsersRequest Model.
Instance Attribute Summary collapse
-
#age ⇒ Integer
User’s age.
-
#is_active ⇒ TrueClass | FalseClass
Whether the user is active.
-
#rating ⇒ Float
User’s rating.
-
#signup_date ⇒ Date
Signup date.
-
#username ⇒ String
User’s username.
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(age = nil, signup_date = nil, username = SKIP, is_active = SKIP, rating = SKIP) ⇒ UsersRequest
constructor
A new instance of UsersRequest.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(age = nil, signup_date = nil, username = SKIP, is_active = SKIP, rating = SKIP) ⇒ UsersRequest
Returns a new instance of UsersRequest.
57 58 59 60 61 62 63 64 |
# File 'lib/test_api/models/users_request.rb', line 57 def initialize(age = nil, signup_date = nil, username = SKIP, is_active = SKIP, = SKIP) @username = username unless username == SKIP @age = age @is_active = is_active unless is_active == SKIP @rating = unless == SKIP @signup_date = signup_date end |
Instance Attribute Details
#age ⇒ Integer
User’s age
18 19 20 |
# File 'lib/test_api/models/users_request.rb', line 18 def age @age end |
#is_active ⇒ TrueClass | FalseClass
Whether the user is active
22 23 24 |
# File 'lib/test_api/models/users_request.rb', line 22 def is_active @is_active end |
#rating ⇒ Float
User’s rating
26 27 28 |
# File 'lib/test_api/models/users_request.rb', line 26 def @rating end |
#signup_date ⇒ Date
Signup date
30 31 32 |
# File 'lib/test_api/models/users_request.rb', line 30 def signup_date @signup_date end |
#username ⇒ String
User’s username
14 15 16 |
# File 'lib/test_api/models/users_request.rb', line 14 def username @username end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/test_api/models/users_request.rb', line 67 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. age = hash.key?('age') ? hash['age'] : nil signup_date = hash.key?('signupDate') ? hash['signupDate'] : nil username = hash.key?('username') ? hash['username'] : SKIP is_active = hash.key?('isActive') ? hash['isActive'] : SKIP = hash.key?('rating') ? hash['rating'] : SKIP # Create object from extracted values. UsersRequest.new(age, signup_date, username, is_active, ) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/test_api/models/users_request.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['username'] = 'username' @_hash['age'] = 'age' @_hash['is_active'] = 'isActive' @_hash['rating'] = 'rating' @_hash['signup_date'] = 'signupDate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/test_api/models/users_request.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 |
# File 'lib/test_api/models/users_request.rb', line 44 def self.optionals %w[ username is_active rating ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
93 94 95 96 97 |
# File 'lib/test_api/models/users_request.rb', line 93 def inspect class_name = self.class.name.split('::').last "<#{class_name} username: #{@username.inspect}, age: #{@age.inspect}, is_active:"\ " #{@is_active.inspect}, rating: #{@rating.inspect}, signup_date: #{@signup_date.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
86 87 88 89 90 |
# File 'lib/test_api/models/users_request.rb', line 86 def to_s class_name = self.class.name.split('::').last "<#{class_name} username: #{@username}, age: #{@age}, is_active: #{@is_active}, rating:"\ " #{@rating}, signup_date: #{@signup_date}>" end |