Class: ApiSchema::Field
- Inherits:
-
Object
- Object
- ApiSchema::Field
- Defined in:
- lib/api_schema/field.rb
Instance Attribute Summary collapse
-
#allowed_values ⇒ Object
Returns the value of attribute allowed_values.
-
#description ⇒ Object
Returns the value of attribute description.
-
#format ⇒ Object
Returns the value of attribute format.
-
#name ⇒ Object
Returns the value of attribute name.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, name, options = {}) ⇒ Field
constructor
A new instance of Field.
- #required? ⇒ Boolean
Constructor Details
#initialize(type, name, options = {}) ⇒ Field
Returns a new instance of Field.
6 7 8 9 10 11 12 13 |
# File 'lib/api_schema/field.rb', line 6 def initialize(type, name, = {}) @type = type @name = name @format = .fetch(:format, nil) @required = .fetch(:required, false) @description = .fetch(:desc, '') @allowed_values = [*.fetch(:allowed_values, nil)] end |
Instance Attribute Details
#allowed_values ⇒ Object
Returns the value of attribute allowed_values.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def allowed_values @allowed_values end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def description @description end |
#format ⇒ Object
Returns the value of attribute format.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def format @format end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def name @name end |
#required ⇒ Object
Returns the value of attribute required.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/api_schema/field.rb', line 4 def type @type end |
Instance Method Details
#required? ⇒ Boolean
15 16 17 |
# File 'lib/api_schema/field.rb', line 15 def required? required end |