Class: Morpher::Transform::Hash::Symbolize

Inherits:
Morpher::Transform show all
Defined in:
lib/morpher/transform.rb

Overview

Transform to symbolize array keys

Instance Method Summary collapse

Methods inherited from Morpher::Transform

#array, #maybe, #seq, #slug, #to_proc

Instance Method Details

#call(input) ⇒ Hash{Symbol => Object}

Apply transformation to input

Parameters:

  • (Hash{String => Object})

Returns:

  • (Hash{Symbol => Object})


325
326
327
328
329
330
331
# File 'lib/morpher/transform.rb', line 325

def call(input)
  unless input.keys.all? { |key| key.instance_of?(String) }
    return failure(error(input: input, message: 'Found non string key in input'))
  end

  success(input.transform_keys(&:to_sym))
end