Class: TestAsdasdasd::Pet
- Defined in:
- lib/test_asdasdasd/models/pet.rb
Overview
Pet Model.
Instance Attribute Summary collapse
-
#category ⇒ Category
TODO: Write general description for this method.
-
#id ⇒ Long
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#photo_urls ⇒ List of String
TODO: Write general description for this method.
-
#status ⇒ Status1Enum
pet status in the store.
-
#tags ⇒ List of Tag
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.
Instance Method Summary collapse
-
#initialize(name = nil, photo_urls = nil, id = nil, category = nil, tags = nil, status = nil) ⇒ Pet
constructor
A new instance of Pet.
Methods inherited from BaseModel
Constructor Details
#initialize(name = nil, photo_urls = nil, id = nil, category = nil, tags = nil, status = nil) ⇒ Pet
Returns a new instance of Pet.
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/test_asdasdasd/models/pet.rb', line 45 def initialize(name = nil, photo_urls = nil, id = nil, category = nil, = nil, status = nil) @id = id @category = category @name = name @photo_urls = photo_urls @tags = @status = status end |
Instance Attribute Details
#category ⇒ Category
TODO: Write general description for this method
15 16 17 |
# File 'lib/test_asdasdasd/models/pet.rb', line 15 def category @category end |
#id ⇒ Long
TODO: Write general description for this method
11 12 13 |
# File 'lib/test_asdasdasd/models/pet.rb', line 11 def id @id end |
#name ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/test_asdasdasd/models/pet.rb', line 19 def name @name end |
#photo_urls ⇒ List of String
TODO: Write general description for this method
23 24 25 |
# File 'lib/test_asdasdasd/models/pet.rb', line 23 def photo_urls @photo_urls end |
#status ⇒ Status1Enum
pet status in the store
31 32 33 |
# File 'lib/test_asdasdasd/models/pet.rb', line 31 def status @status end |
#tags ⇒ List of Tag
TODO: Write general description for this method
27 28 29 |
# File 'lib/test_asdasdasd/models/pet.rb', line 27 def @tags end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/test_asdasdasd/models/pet.rb', line 60 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash['name'] photo_urls = hash['photoUrls'] id = hash['id'] category = Category.from_hash(hash['category']) if hash['category'] # Parameter is an array, so we need to iterate through it = nil unless hash['tags'].nil? = [] hash['tags'].each do |structure| << (Tag.from_hash(structure) if structure) end end status = hash['status'] # Create object from extracted values. Pet.new(name, photo_urls, id, category, , status) end |
.names ⇒ Object
A mapping from model property names to API property names.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/test_asdasdasd/models/pet.rb', line 34 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['category'] = 'category' @_hash['name'] = 'name' @_hash['photo_urls'] = 'photoUrls' @_hash['tags'] = 'tags' @_hash['status'] = 'status' @_hash end |