Class: Serega::SeregaUtils::FormatUserPreloads

Inherits:
Object
  • Object
show all
Defined in:
lib/serega/utils/format_user_preloads.rb

Overview

Utility that helps to transform user provided preloads to hash

Class Method Summary collapse

Class Method Details

.call(value) ⇒ Hash

Transforms user provided preloads to hash

Parameters:

  • value (Array, Hash, String, Symbol, nil, false)

    preloads

Returns:

  • (Hash)

    preloads transformed to hash



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/serega/utils/format_user_preloads.rb', line 17

def call(value)
  case value
  when Array then array_to_hash(value)
  when FalseClass then nil_to_hash(value)
  when Hash then hash_to_hash(value)
  when NilClass then nil_to_hash(value)
  when String then string_to_hash(value)
  when Symbol then symbol_to_hash(value)
  else raise Serega::SeregaError,
    "Preload option value can consist from Symbols, Arrays, Hashes (#{value.class} #{value.inspect} was provided)"
  end
end