Class: GoonModelGen::Source::Enum
- Defined in:
- lib/goon_model_gen/source/enum.rb
Defined Under Namespace
Classes: Element
Instance Attribute Summary collapse
-
#base_type ⇒ Object
readonly
Returns the value of attribute base_type.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Attributes inherited from Type
Attributes included from Contextual
Instance Method Summary collapse
-
#initialize(name, base_type, element_definitions) ⇒ Enum
constructor
A new instance of Enum.
Constructor Details
#initialize(name, base_type, element_definitions) ⇒ Enum
Returns a new instance of Enum.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/goon_model_gen/source/enum.rb', line 21 def initialize(name, base_type, element_definitions) unless element_definitions.all?{|i| i.is_a?(Hash) && (i.length == 1) } raise "Enum element definitions must be an Array of 1 element Hash but was #{element_definitions.inspect}" end super(name) @base_type = base_type @elements = element_definitions.map do |i| Element.new(i.keys.first, i.values.first) end end |
Instance Attribute Details
#base_type ⇒ Object (readonly)
Returns the value of attribute base_type.
16 17 18 |
# File 'lib/goon_model_gen/source/enum.rb', line 16 def base_type @base_type end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
16 17 18 |
# File 'lib/goon_model_gen/source/enum.rb', line 16 def elements @elements end |