Class: Apia::Definitions::Enum

Inherits:
Apia::Definition show all
Defined in:
lib/apia/definitions/enum.rb

Instance Attribute Summary collapse

Attributes inherited from Apia::Definition

#description, #id, #name, #schema

Instance Method Summary collapse

Methods inherited from Apia::Definition

#initialize, #schema?

Constructor Details

This class inherits a constructor from Apia::Definition

Instance Attribute Details

#castObject

Returns the value of attribute cast.



10
11
12
# File 'lib/apia/definitions/enum.rb', line 10

def cast
  @cast
end

#valuesObject (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

#dslObject



17
18
19
# File 'lib/apia/definitions/enum.rb', line 17

def dsl
  @dsl ||= DSLs::Enum.new(self)
end

#setupObject



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