Class: Useless::Doc::Core::Body::Attribute
- Inherits:
-
Object
- Object
- Useless::Doc::Core::Body::Attribute
- Defined in:
- lib/useless/doc/core/body.rb
Overview
Documentation for an attribute on an HTTP body.
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#description ⇒ String
readonly
A description of the attribute.
-
#key ⇒ String
readonly
The key of this attribute in the body.
-
#required ⇒ Boolean
readonly
Whether or not the attribute is required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value_type ⇒ String
readonly
One of “string”, “number”, “object”, “array”, or “boolean”.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(attrs) ⇒ Attribute
Returns a new instance of Attribute.
49 50 51 52 53 54 55 |
# File 'lib/useless/doc/core/body.rb', line 49 def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
45 46 47 |
# File 'lib/useless/doc/core/body.rb', line 45 def default @default end |
#description ⇒ String (readonly)
Returns a description of the attribute.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/useless/doc/core/body.rb', line 43 class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end |
#key ⇒ String (readonly)
Returns the key of this attribute in the body.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/useless/doc/core/body.rb', line 43 class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end |
#required ⇒ Boolean (readonly)
Returns whether or not the attribute is required. If it is required, and the attribute is omitted, the response should have a 4xx code. true
is the default value.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/useless/doc/core/body.rb', line 43 class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
45 46 47 |
# File 'lib/useless/doc/core/body.rb', line 45 def type @type end |
#value_type ⇒ String (readonly)
Returns one of “string”, “number”, “object”, “array”, or “boolean”. “string” is the default value.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/useless/doc/core/body.rb', line 43 class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end |