Class: Useless::Doc::Core::Body::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/doc/core/body.rb

Overview

Documentation for an attribute on an HTTP body.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • attrs (Hash)

    corresponds to the class’s instance attributes.



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

#attributesArray<Body::Attribute> (readonly)

Returns documentation for the sub-attributes of this attribute. An empty array is the default value.

Returns:

  • (Array<Body::Attribute>)

    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

#defaultObject (readonly)

Returns the value of attribute default.



50
51
52
# File 'lib/useless/doc/core/body.rb', line 50

def default
  @default
end

#descriptionString (readonly)

Returns a description of the attribute.

Returns:

  • (String)

    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

#keyString (readonly)

Returns the key of this attribute in the body.

Returns:

  • (String)

    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

#requiredBoolean (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.

Returns:

  • (Boolean)

    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

#typeObject (readonly)

Returns the value of attribute type.



50
51
52
# File 'lib/useless/doc/core/body.rb', line 50

def type
  @type
end

#value_typeString (readonly)

Returns one of “string”, “number”, “object”, “array”, or “boolean”. “string” is the default value.

Returns:

  • (String)

    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