Class: SwaggerModel::SwaggerV2::RelationDataArray

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_model/relation_data_array.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(array) ⇒ RelationDataArray

Returns a new instance of RelationDataArray.



7
8
9
10
11
12
# File 'lib/swagger_model/relation_data_array.rb', line 7

def initialize(array)
  if array.size > 0
    @relation = Relation.new(array.first)
  end

end

Instance Attribute Details

#relationObject

Returns the value of attribute relation.



6
7
8
# File 'lib/swagger_model/relation_data_array.rb', line 6

def relation
  @relation
end

Instance Method Details

#to_swagger_hash(key, parent_name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/swagger_model/relation_data_array.rb', line 14

def to_swagger_hash(key, parent_name)
  if @relation.nil?
    return nil
  end
  name = parent_name + ActiveSupport::Inflector.classify(key.gsub('-', '_')) + 'Data'
  {
    name => {
      'type' => 'object',
      'properties' => {
        'data' => {
          'type' => 'array',
          'items' => @relation.to_swagger_hash
        }
      }
    }
  }
end