Class: Apigen::Rest::Output
- Inherits:
-
Object
- Object
- Apigen::Rest::Output
- Defined in:
- lib/apigen/rest/output.rb
Overview
Output is the response type associated with a specific status code for an API endpoint.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name) ⇒ Output
constructor
A new instance of Output.
- #to_s ⇒ Object
-
#type(type = nil, &block) ⇒ Object
Declares the output type.
- #validate(model_registry) ⇒ Object
Constructor Details
#initialize(name) ⇒ Output
Returns a new instance of Output.
13 14 15 16 17 18 |
# File 'lib/apigen/rest/output.rb', line 13 def initialize(name) @name = name @status = nil @type = nil @description = nil end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/apigen/rest/output.rb', line 8 def name @name end |
Instance Method Details
#to_s ⇒ Object
32 33 34 |
# File 'lib/apigen/rest/output.rb', line 32 def to_s "#{@name} #{@status} #{@type}" end |
#type(type = nil, &block) ⇒ Object
Declares the output type.
22 23 24 25 |
# File 'lib/apigen/rest/output.rb', line 22 def type(type = nil, &block) return @type unless type @type = Apigen::Model.type type, &block end |
#validate(model_registry) ⇒ Object
27 28 29 30 |
# File 'lib/apigen/rest/output.rb', line 27 def validate(model_registry) validate_properties model_registry.check_type @type end |