class Morpher::Transform

Composable transform declaration and execution

Constants

BOOLEAN
FLOAT
INTEGER
STRING
STRING_ARRAY

Public Instance Methods

array() click to toggle source

Build array transform

@return [Transform]

# File lib/morpher/transform.rb, line 35
def array
  Array.new(self)
end
maybe() click to toggle source

Build maybe transform

@return [Transform]

# File lib/morpher/transform.rb, line 42
def maybe
  Maybe.new(self)
end
seq(transform) click to toggle source

Build sequence

@param [Transform] transform

@return [Transform]

# File lib/morpher/transform.rb, line 28
def seq(transform)
  Sequence.new([self, transform])
end
slug() click to toggle source

Default slug

@return [String]

# File lib/morpher/transform.rb, line 12
def slug
  self.class.to_s
end
to_proc() click to toggle source

Build Proc to transform input

@return [Proc]

# File lib/morpher/transform.rb, line 49
def to_proc
  public_method(:call).to_proc
end

Private Instance Methods

error(input:, cause: nil, message: nil) click to toggle source
# File lib/morpher/transform.rb, line 137
def error(input:, cause: nil, message: nil)
  Error.new(
    cause:     cause,
    input:     input,
    message:   message,
    transform: self
  )
end
failure(value) click to toggle source
# File lib/morpher/transform.rb, line 154
def failure(value)
  Either::Left.new(value)
end
lift_error(error) click to toggle source
# File lib/morpher/transform.rb, line 146
def lift_error(error)
  error.with(transform: self)
end
success(value) click to toggle source
# File lib/morpher/transform.rb, line 158
def success(value)
  Either::Right.new(value)
end
wrap_error(error) click to toggle source
# File lib/morpher/transform.rb, line 150
def wrap_error(error)
  error(cause: error, input: error.input)
end