Module: Castkit::DataObjectExtensions::Deserialization::ClassMethods

Defined in:
lib/castkit/data_object_extensions/deserialization.rb

Overview

Class-level deserialization helpers.

Instance Method Summary collapse

Instance Method Details

#from_hash(hash) ⇒ Castkit::DataObject Also known as: from_h, creator

Builds a new instance from a Hash, symbolizing keys as needed.

Parameters:

  • hash (Hash)

Returns:



22
23
24
25
# File 'lib/castkit/data_object_extensions/deserialization.rb', line 22

def from_hash(hash)
  hash = hash.transform_keys { |k| k.respond_to?(:to_sym) ? k.to_sym : k }
  new(hash)
end