Class: FancyHash::Types::Enum
- Inherits:
-
ActiveModel::Type::Value
- Object
- ActiveModel::Type::Value
- FancyHash::Types::Enum
- Defined in:
- lib/fancy_hash.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(of:) ⇒ Enum
constructor
A new instance of Enum.
- #serialize(value) ⇒ Object
Constructor Details
#initialize(of:) ⇒ Enum
99 100 101 102 103 |
# File 'lib/fancy_hash.rb', line 99 def initialize(of:) super() @config = of.stringify_keys end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
97 98 99 |
# File 'lib/fancy_hash.rb', line 97 def config @config end |
Instance Method Details
#serialize(value) ⇒ Object
105 106 107 108 109 |
# File 'lib/fancy_hash.rb', line 105 def serialize(value) return value if config.value?(value) config[value.to_s] end |