Class: Morpher::Transform::Hash

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

Overview

Transform a hash via mapping it over key specific transforms

Defined Under Namespace

Classes: Key, Symbolize

Constant Summary collapse

KEY_MESSAGE =
'Missing keys: %<missing>s, Unexpected keys: %<unexpected>s'
PRIMITIVE =
Primitive.new(::Hash)

Instance Method Summary collapse

Methods inherited from Morpher::Transform

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

Instance Method Details

#call(input) ⇒ Either<Error, Object>

Apply transformation to input

Parameters:

  • input (Object)

Returns:



363
364
365
366
367
368
369
# File 'lib/morpher/transform.rb', line 363

def call(input)
  PRIMITIVE
    .call(input)
    .lmap(&method(:lift_error))
    .bind(&method(:reject_keys))
    .bind(&method(:transform))
end