t6d / smart_properties

Ruby accessors on steroids
MIT License
177 stars 20 forks source link

Hash Serialization Plugin #85

Closed t6d closed 3 years ago

t6d commented 3 years ago

Support serialization through #to_hash and #to_h and deserialization through augmenting the constructor. The plugin can be used in the following two ways:

  1. include SmartProperties(SmartProperties::Plugins::HashSerialization)
  2. include SmartProperties(SmartProperties::Plugins::HashSerialization.without_optionals)

In the latter case, #to_hash will remove all keys that point to a nil value during serialization.