Class: ReeEnum::BaseEnumMapper
- Inherits:
-
ReeMapper::AbstractType
- Object
- ReeMapper::AbstractType
- ReeEnum::BaseEnumMapper
- Defined in:
- lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#enum ⇒ Object
readonly
Returns the value of attribute enum.
Instance Method Summary collapse
- #db_dump(value) ⇒ Object
- #db_load(value) ⇒ Object
-
#initialize(enum) ⇒ BaseEnumMapper
constructor
A new instance of BaseEnumMapper.
Constructor Details
#initialize(enum) ⇒ BaseEnumMapper
Returns a new instance of BaseEnumMapper.
7 8 9 |
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb', line 7 def initialize(enum) @enum = enum end |
Instance Attribute Details
#enum ⇒ Object (readonly)
Returns the value of attribute enum.
5 6 7 |
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb', line 5 def enum @enum end |
Instance Method Details
#db_dump(value) ⇒ Object
12 13 14 |
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb', line 12 def db_dump(value) value.mapped_value end |
#db_load(value) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ree_lib/packages/ree_enum/package/ree_enum/base_enum_mapper.rb', line 17 def db_load(value) enum_val = @enum.get_values.by_mapped_value(value) if !enum_val raise ReeMapper::CoercionError.new("should be one of #{enum_inspection}, got `#{truncate(value.inspect)}`") end enum_val end |