Class: Morpher::Transform::Boolean

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

Overview

Transform guarding boolean primitives

Constant Summary collapse

MESSAGE =
'Expected: boolean but got: %<actual>s'

Instance Method Summary collapse

Methods inherited from Morpher::Transform

#array, #maybe, #seq, #slug

Instance Method Details

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

Apply transformation to input

Parameters:

  • input (Object)

Returns:



242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/morpher/transform.rb', line 242

def call(input)
  if input.equal?(true) || input.equal?(false)
    success(input)
  else
    failure(
      error(
        message: MESSAGE % { actual: input.inspect },
        input:   input
      )
    )
  end
end