Class: Mutant::Transform::Primitive Private

Inherits:
Mutant::Transform show all
Defined in:
lib/mutant/transform.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Transform guarding a specific primitive

Constant Summary collapse

MESSAGE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Expected: %<expected>s but got: %<actual>s'

Instance Method Summary collapse

Instance Method Details

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Apply transformation to input

Parameters:

  • input (Object)

Returns:



199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/mutant/transform.rb', line 199

def apply(input)
  if input.instance_of?(primitive)
    success(input)
  else
    failure(
      error(
        input:   input,
        message: MESSAGE % { actual: input.class, expected: primitive }
      )
    )
  end
end

#slugString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Rendering slug

Returns:

  • (String)


215
216
217
# File 'lib/mutant/transform.rb', line 215

def slug
  primitive.to_s
end