Class: Serega::SeregaUtils::ToHash
- Inherits:
-
Object
- Object
- Serega::SeregaUtils::ToHash
- Defined in:
- lib/serega/utils/to_hash.rb
Overview
Utility to transform almost anything to Hash
Class Method Summary collapse
-
.call(value) ⇒ Hash
Constructs deep hashes from provided data.
Class Method Details
.call(value) ⇒ Hash
Constructs deep hashes from provided data
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/serega/utils/to_hash.rb', line 27 def call(value) case value when Array then array_to_hash(value) when Hash then hash_to_hash(value) when NilClass, FalseClass then nil_to_hash(value) when String then string_to_hash(value) when Symbol then symbol_to_hash(value) else raise SeregaError, "Cant convert #{value.class} class object to hash" end end |