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.



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

#defaultObject (readonly)

Returns the value of attribute default.



45
46
47
# File 'lib/useless/doc/core/body.rb', line 45

def default
  @default
end

#descriptionString (readonly)

Returns a description of the attribute.

Returns:

  • (String)

    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

#keyString (readonly)

Returns the key of this attribute in the body.

Returns:

  • (String)

    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

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



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

#typeObject (readonly)

Returns the value of attribute type.



45
46
47
# File 'lib/useless/doc/core/body.rb', line 45

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.



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