Class: Alchemrest::Transforms::LooseHash

Inherits:
Morpher::Transform
  • Object
show all
Defined in:
lib/alchemrest/transforms/loose_hash.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

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

Apply transformation to input

Parameters:

  • input (Object)

Returns:

  • (Either<Error, Object>)


18
19
20
21
22
23
24
# File 'lib/alchemrest/transforms/loose_hash.rb', line 18

def call(input)
  PRIMITIVE
    .call(input)
    .lmap { |e| lift_error(e) }
    .bind { |o| reject_keys(o) }
    .bind { |o| transform(o) }
end