Class: NumeritajTipo::EnumType
- Inherits:
-
Object
- Object
- NumeritajTipo::EnumType
- Defined in:
- lib/numeritaj_tipo/enum_type.rb
Instance Attribute Summary collapse
-
#enum_values ⇒ Object
readonly
Returns the value of attribute enum_values.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type, values) ⇒ EnumType
constructor
A new instance of EnumType.
- #values_for_validation ⇒ Object
Constructor Details
#initialize(type, values) ⇒ EnumType
Returns a new instance of EnumType.
5 6 7 8 |
# File 'lib/numeritaj_tipo/enum_type.rb', line 5 def initialize(type, values) @type = type.to_s.classify.constantize @enum_values = @type < NumeritajTipo::EnumBase ? @type.values : values end |
Instance Attribute Details
#enum_values ⇒ Object (readonly)
Returns the value of attribute enum_values.
3 4 5 |
# File 'lib/numeritaj_tipo/enum_type.rb', line 3 def enum_values @enum_values end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/numeritaj_tipo/enum_type.rb', line 3 def type @type end |
Instance Method Details
#values_for_validation ⇒ Object
10 11 12 13 14 |
# File 'lib/numeritaj_tipo/enum_type.rb', line 10 def values_for_validation return enum_values unless type < NumeritajTipo::EnumBase enum_values.map {|value| type.build(value) } end |