Class: WebFunction::Attribute
- Inherits:
-
Object
- Object
- WebFunction::Attribute
- Defined in:
- lib/web_function/attribute.rb
Overview
# Attribute
An Attribute defines an output field that may be produced and returned by a Web Function endpoint.
See the [attributes section] on the Web Function website for more details about attribute definitions, recognized keys, and usage.
Instance Method Summary collapse
-
#docs ⇒ String
## Docs.
-
#flags ⇒ Array<String>
## Flags.
-
#hint ⇒ String?
## Hint.
-
#initialize(attribute) ⇒ Attribute
constructor
A new instance of Attribute.
-
#name ⇒ String
## Name.
-
#type ⇒ String
## Type.
-
#values ⇒ Array
## Values.
Constructor Details
#initialize(attribute) ⇒ Attribute
Returns a new instance of Attribute.
15 16 17 |
# File 'lib/web_function/attribute.rb', line 15 def initialize(attribute) @attribute = attribute end |
Instance Method Details
#docs ⇒ String
## Docs
A markdown string describing this attribute and its purpose in the output object. Used by documentation tools, and highly recommended.
96 97 98 |
# File 'lib/web_function/attribute.rb', line 96 def docs @attribute["docs"].to_s end |
#flags ⇒ Array<String>
## Flags
An array of attribute flags. Flags describe special characteristics or behaviors of attributes. See the [available flags section] for complete list and documentation.
85 86 87 |
# File 'lib/web_function/attribute.rb', line 85 def flags [*@attribute["flags"]].map(&:to_s) end |
#hint ⇒ String?
## Hint
A string hinting about the semantics of this attribute. See the
- hints section][1
-
for possible values and documentation tooling guidance.
56 57 58 |
# File 'lib/web_function/attribute.rb', line 56 def hint @attribute["hint"] end |
#name ⇒ String
## Name
The name of the attribute as it will appear in the endpoint’s output object.
26 27 28 |
# File 'lib/web_function/attribute.rb', line 26 def name @attribute["name"] end |
#type ⇒ String
## Type
The type of value returned for this attribute. Must be one of:
- object
- array
- string
- number
- boolean
This is a required string.
43 44 45 |
# File 'lib/web_function/attribute.rb', line 43 def type @attribute["type"] end |
#values ⇒ Array
## Values
An array specifying the exact, case-sensitive values that may be returned for this attribute. Each value in the values array must conform to the data type specified in the “type” key.
This is useful for attributes that can only take a select set of values (enums or constants).
71 72 73 |
# File 'lib/web_function/attribute.rb', line 71 def values [*@attribute["values"]] end |