Class: CryptReboot::SingleAssignRestrictedMap
- Inherits:
-
Object
- Object
- CryptReboot::SingleAssignRestrictedMap
- Defined in:
- lib/crypt_reboot/single_assign_restricted_map.rb
Overview
Hash-like class allowing to assign value only once to a list of allowed keys
Constant Summary collapse
- AlreadyAssigned =
Class.new StandardError
Instance Method Summary collapse
Instance Method Details
#[]=(field, value) ⇒ Object
8 9 10 11 12 |
# File 'lib/crypt_reboot/single_assign_restricted_map.rb', line 8 def []=(field, value) raise AlreadyAssigned, "Value already assigned for `#{field}` field" if data.key? field data[field] = value end |
#to_h ⇒ Object
14 15 16 |
# File 'lib/crypt_reboot/single_assign_restricted_map.rb', line 14 def to_h data end |