Class: TestPack1::SiteWithData
- Defined in:
- lib/test_pack_1/models/site_with_data.rb
Overview
SiteWithData Model.
Instance Attribute Summary collapse
-
#country ⇒ String
The id of a site.
-
#identity ⇒ String
The id of a site.
-
#metadata ⇒ List of MetadataField
A list of metadata fields and their values.
-
#site_id ⇒ Integer
The id of a site.
-
#title ⇒ String
The id of a site.
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(site_id = nil, title = nil, country = nil, identity = nil, metadata = nil) ⇒ SiteWithData
constructor
A new instance of SiteWithData.
Methods inherited from BaseModel
Constructor Details
#initialize(site_id = nil, title = nil, country = nil, identity = nil, metadata = nil) ⇒ SiteWithData
Returns a new instance of SiteWithData.
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 40 def initialize(site_id = nil, title = nil, country = nil, identity = nil, = nil) @site_id = site_id @title = title @country = country @identity = identity @metadata = end |
Instance Attribute Details
#country ⇒ String
The id of a site.
19 20 21 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 19 def country @country end |
#identity ⇒ String
The id of a site.
23 24 25 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 23 def identity @identity end |
#metadata ⇒ List of MetadataField
A list of metadata fields and their values.
27 28 29 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 27 def @metadata end |
#site_id ⇒ Integer
The id of a site.
11 12 13 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 11 def site_id @site_id end |
#title ⇒ String
The id of a site.
15 16 17 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 15 def title @title end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 53 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. site_id = hash['siteId'] title = hash['title'] country = hash['country'] identity = hash['identity'] # Parameter is an array, so we need to iterate through it = nil unless hash['metadata'].nil? = [] hash['metadata'].each do |structure| << (MetadataField.from_hash(structure) if structure) end end # Create object from extracted values. SiteWithData.new(site_id, title, country, identity, ) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 38 |
# File 'lib/test_pack_1/models/site_with_data.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['site_id'] = 'siteId' @_hash['title'] = 'title' @_hash['country'] = 'country' @_hash['identity'] = 'identity' @_hash['metadata'] = 'metadata' @_hash end |