Class: CypressTestApi::Item
- Defined in:
- lib/cypress_test_api/models/item.rb
Overview
Item Model.
Instance Attribute Summary collapse
-
#animal ⇒ Object
A generic JSON object.
-
#bool ⇒ TrueClass | FalseClass
TODO: Write general description for this method.
-
#custom_enum ⇒ CustomEnum
TODO: Write general description for this method.
-
#date ⇒ Date
TODO: Write general description for this method.
-
#date_time ⇒ DateTime
TODO: Write general description for this method.
-
#decimal ⇒ Float
TODO: Write general description for this method.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#json_object ⇒ Object
A generic JSON object.
-
#long ⇒ Integer
TODO: Write general description for this method.
-
#map ⇒ Hash[String, Message]
A generic JSON object.
-
#name ⇒ String
TODO: Write general description for this method.
-
#status ⇒ StatusEnum
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 = nil, name = nil, date = nil, date_time = nil, decimal = nil, long = nil, bool = nil, custom_enum = nil, json_object = nil, animal = nil, map = nil, status = SKIP) ⇒ Item
constructor
A new instance of Item.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_date_time ⇒ Object
-
#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(id = nil, name = nil, date = nil, date_time = nil, decimal = nil, long = nil, bool = nil, custom_enum = nil, json_object = nil, animal = nil, map = nil, status = SKIP) ⇒ Item
Returns a new instance of Item.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/cypress_test_api/models/item.rb', line 91 def initialize(id = nil, name = nil, date = nil, date_time = nil, decimal = nil, long = nil, bool = nil, custom_enum = nil, json_object = nil, animal = nil, map = nil, status = SKIP) @id = id @name = name @date = date @date_time = date_time @decimal = decimal @long = long @bool = bool @custom_enum = custom_enum @status = status unless status == SKIP @json_object = json_object @animal = animal @map = map end |
Instance Attribute Details
#animal ⇒ Object
A generic JSON object
55 56 57 |
# File 'lib/cypress_test_api/models/item.rb', line 55 def animal @animal end |
#bool ⇒ TrueClass | FalseClass
TODO: Write general description for this method
39 40 41 |
# File 'lib/cypress_test_api/models/item.rb', line 39 def bool @bool end |
#custom_enum ⇒ CustomEnum
TODO: Write general description for this method
43 44 45 |
# File 'lib/cypress_test_api/models/item.rb', line 43 def custom_enum @custom_enum end |
#date ⇒ Date
TODO: Write general description for this method
23 24 25 |
# File 'lib/cypress_test_api/models/item.rb', line 23 def date @date end |
#date_time ⇒ DateTime
TODO: Write general description for this method
27 28 29 |
# File 'lib/cypress_test_api/models/item.rb', line 27 def date_time @date_time end |
#decimal ⇒ Float
TODO: Write general description for this method
31 32 33 |
# File 'lib/cypress_test_api/models/item.rb', line 31 def decimal @decimal end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/cypress_test_api/models/item.rb', line 15 def id @id end |
#json_object ⇒ Object
A generic JSON object
51 52 53 |
# File 'lib/cypress_test_api/models/item.rb', line 51 def json_object @json_object end |
#long ⇒ Integer
TODO: Write general description for this method
35 36 37 |
# File 'lib/cypress_test_api/models/item.rb', line 35 def long @long end |
#map ⇒ Hash[String, Message]
A generic JSON object
59 60 61 |
# File 'lib/cypress_test_api/models/item.rb', line 59 def map @map end |
#name ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/cypress_test_api/models/item.rb', line 19 def name @name end |
#status ⇒ StatusEnum
TODO: Write general description for this method
47 48 49 |
# File 'lib/cypress_test_api/models/item.rb', line 47 def status @status end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/cypress_test_api/models/item.rb', line 109 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil name = hash.key?('name') ? hash['name'] : nil date = hash.key?('date') ? hash['date'] : nil date_time = if hash.key?('dateTime') (DateTimeHelper.from_rfc3339(hash['dateTime']) if hash['dateTime']) end decimal = hash.key?('decimal') ? hash['decimal'] : nil long = hash.key?('long') ? hash['long'] : nil bool = hash.key?('bool') ? hash['bool'] : nil custom_enum = hash.key?('CustomEnum') ? hash['CustomEnum'] : nil json_object = hash.key?('jsonObject') ? hash['jsonObject'] : nil animal = hash.key?('Animal') ? hash['Animal'] : nil map = Message.from_hash(hash['Map']) if hash['Map'] map = nil unless hash.key?('Map') status = hash.key?('status') ? hash['status'] : SKIP # Create object from extracted values. Item.new(id, name, date, date_time, decimal, long, bool, custom_enum, json_object, animal, map, status) end |
.names ⇒ Object
A mapping from model property names to API property names.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cypress_test_api/models/item.rb', line 62 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['date'] = 'date' @_hash['date_time'] = 'dateTime' @_hash['decimal'] = 'decimal' @_hash['long'] = 'long' @_hash['bool'] = 'bool' @_hash['custom_enum'] = 'CustomEnum' @_hash['status'] = 'status' @_hash['json_object'] = 'jsonObject' @_hash['animal'] = 'Animal' @_hash['map'] = 'Map' @_hash end |
.nullables ⇒ Object
An array for nullable fields
87 88 89 |
# File 'lib/cypress_test_api/models/item.rb', line 87 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
80 81 82 83 84 |
# File 'lib/cypress_test_api/models/item.rb', line 80 def self.optionals %w[ status ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
158 159 160 161 162 163 164 |
# File 'lib/cypress_test_api/models/item.rb', line 158 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, name: #{@name.inspect}, date: #{@date.inspect},"\ " date_time: #{@date_time.inspect}, decimal: #{@decimal.inspect}, long: #{@long.inspect},"\ " bool: #{@bool.inspect}, custom_enum: #{@custom_enum.inspect}, status: #{@status.inspect},"\ " json_object: #{@json_object.inspect}, animal: #{@animal.inspect}, map: #{@map.inspect}>" end |
#to_custom_date_time ⇒ Object
145 146 147 |
# File 'lib/cypress_test_api/models/item.rb', line 145 def to_custom_date_time DateTimeHelper.to_rfc3339(date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
150 151 152 153 154 155 |
# File 'lib/cypress_test_api/models/item.rb', line 150 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, name: #{@name}, date: #{@date}, date_time: #{@date_time},"\ " decimal: #{@decimal}, long: #{@long}, bool: #{@bool}, custom_enum: #{@custom_enum},"\ " status: #{@status}, json_object: #{@json_object}, animal: #{@animal}, map: #{@map}>" end |