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
-
#attributes ⇒ Array<Body::Attribute>
readonly
Documentation for the sub-attributes of this attribute.
-
#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.
55 56 57 58 59 60 61 62 |
# File 'lib/useless/doc/core/body.rb', line 55 def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] @attributes = attrs[:attributes] || [] end |
Instance Attribute Details
#attributes ⇒ Array<Body::Attribute> (readonly)
Returns documentation for the sub-attributes of this attribute. An empty array is the default value.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/useless/doc/core/body.rb', line 48 class Attribute attr_reader :key, :type, :required, :default, :description, :attributes # @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] @attributes = attrs[:attributes] || [] end end |
#default ⇒ Object (readonly)
Returns the value of attribute default.
50 51 52 |
# File 'lib/useless/doc/core/body.rb', line 50 def default @default end |
#description ⇒ String (readonly)
Returns a description of the attribute.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/useless/doc/core/body.rb', line 48 class Attribute attr_reader :key, :type, :required, :default, :description, :attributes # @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] @attributes = attrs[:attributes] || [] end end |
#key ⇒ String (readonly)
Returns the key of this attribute in the body.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/useless/doc/core/body.rb', line 48 class Attribute attr_reader :key, :type, :required, :default, :description, :attributes # @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] @attributes = attrs[:attributes] || [] 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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/useless/doc/core/body.rb', line 48 class Attribute attr_reader :key, :type, :required, :default, :description, :attributes # @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] @attributes = attrs[:attributes] || [] end end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
50 51 52 |
# File 'lib/useless/doc/core/body.rb', line 50 def type @type end |
#value_type ⇒ String (readonly)
Returns one of “string”, “number”, “object”, “array”, or “boolean”. “string” is the default value.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/useless/doc/core/body.rb', line 48 class Attribute attr_reader :key, :type, :required, :default, :description, :attributes # @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] @attributes = attrs[:attributes] || [] end end |