Class: Swaggard::Swagger::Definition
- Inherits:
-
Object
- Object
- Swaggard::Swagger::Definition
- Defined in:
- lib/swaggard/swagger/definition.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #add_property(property) ⇒ Object
-
#initialize(id) ⇒ Definition
constructor
A new instance of Definition.
- #to_doc ⇒ Object
Constructor Details
#initialize(id) ⇒ Definition
Returns a new instance of Definition.
7 8 9 10 |
# File 'lib/swaggard/swagger/definition.rb', line 7 def initialize(id) @id = id @properties = [] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/swaggard/swagger/definition.rb', line 5 def id @id end |
Instance Method Details
#add_property(property) ⇒ Object
12 13 14 |
# File 'lib/swaggard/swagger/definition.rb', line 12 def add_property(property) @properties << property end |
#to_doc ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/swaggard/swagger/definition.rb', line 16 def to_doc { 'type' => 'object', 'required' => [], 'properties' => Hash[@properties.map { |property| [property.id, property.to_doc] }] } end |