Class: Apigen::EnumType
- Inherits:
-
Object
- Object
- Apigen::EnumType
- Defined in:
- lib/apigen/models/enum_type.rb
Overview
EnumType represents an enum (a type that can be one of several constants).
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize ⇒ EnumType
constructor
A new instance of EnumType.
- #validate(_model_registry) ⇒ Object
- #value(val) ⇒ Object
Constructor Details
#initialize ⇒ EnumType
Returns a new instance of EnumType.
11 12 13 |
# File 'lib/apigen/models/enum_type.rb', line 11 def initialize @values = [] end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
9 10 11 |
# File 'lib/apigen/models/enum_type.rb', line 9 def values @values end |
Instance Method Details
#validate(_model_registry) ⇒ Object
19 20 21 22 23 |
# File 'lib/apigen/models/enum_type.rb', line 19 def validate(_model_registry) @values.each do |val| raise 'Enums only support string values' unless val.is_a? String end end |
#value(val) ⇒ Object
15 16 17 |
# File 'lib/apigen/models/enum_type.rb', line 15 def value(val) @values << val end |