Class: Morpher::Transform::Primitive
- Inherits:
-
Morpher::Transform
- Object
- Morpher::Transform
- Morpher::Transform::Primitive
- Defined in:
- lib/morpher/transform.rb
Overview
Transform guarding a specific primitive
Constant Summary collapse
- MESSAGE =
'Expected: %<expected>s but got: %<actual>s'
Instance Method Summary collapse
-
#call(input) ⇒ Either<Error, Object>
Apply transformation to input.
-
#slug ⇒ String
Rendering slug.
Instance Method Details
#call(input) ⇒ Either<Error, Object>
Apply transformation to input
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/morpher/transform.rb', line 184 def call(input) if input.instance_of?(primitive) success(input) else failure( error( input: input, message: MESSAGE % { actual: input.class, expected: primitive } ) ) end end |
#slug ⇒ String
Rendering slug
200 201 202 |
# File 'lib/morpher/transform.rb', line 200 def slug primitive.to_s end |