Class: Renum::NameSerializer
- Inherits:
-
Object
- Object
- Renum::NameSerializer
- Defined in:
- lib/renum/name_serializer.rb
Instance Method Summary collapse
- #dump(v) ⇒ Object
-
#initialize(enum_class) ⇒ NameSerializer
constructor
A new instance of NameSerializer.
- #load(s) ⇒ Object
Constructor Details
#initialize(enum_class) ⇒ NameSerializer
Returns a new instance of NameSerializer.
3 4 5 |
# File 'lib/renum/name_serializer.rb', line 3 def initialize enum_class @enum_class = enum_class end |
Instance Method Details
#dump(v) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/renum/name_serializer.rb', line 7 def dump v v && if v.is_a?(String) v else v.name end end |
#load(s) ⇒ Object
15 16 17 |
# File 'lib/renum/name_serializer.rb', line 15 def load s s && @enum_class.with_name(s) end |