Class: Apia::Definitions::Enum
- Inherits:
-
Apia::Definition
- Object
- Apia::Definition
- Apia::Definitions::Enum
- Defined in:
- lib/apia/definitions/enum.rb
Instance Attribute Summary collapse
-
#cast ⇒ Object
Returns the value of attribute cast.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from Apia::Definition
#description, #id, #name, #schema
Instance Method Summary collapse
Methods inherited from Apia::Definition
Constructor Details
This class inherits a constructor from Apia::Definition
Instance Attribute Details
#cast ⇒ Object
Returns the value of attribute cast.
10 11 12 |
# File 'lib/apia/definitions/enum.rb', line 10 def cast @cast end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
11 12 13 |
# File 'lib/apia/definitions/enum.rb', line 11 def values @values end |
Instance Method Details
#dsl ⇒ Object
17 18 19 |
# File 'lib/apia/definitions/enum.rb', line 17 def dsl @dsl ||= DSLs::Enum.new(self) end |
#setup ⇒ Object
13 14 15 |
# File 'lib/apia/definitions/enum.rb', line 13 def setup @values = {} end |
#validate(errors) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/apia/definitions/enum.rb', line 21 def validate(errors) if cast && !cast.is_a?(Proc) errors.add self, 'CastMustBeProc', 'The value provided for casting an enum must be an instance of Proc' end true end |