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

#slug

Instance Method Details

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

Apply transformation to input

Parameters:

  • input (Object)

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/morpher/transform.rb', line 219

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