module Remap::Mapper::API

Public Instance Methods

call(input, backtrace: caller, **options, &error) click to toggle source

@param input [Any] @param backtrace [Array<String>] @param options [Hash]

@yieldparam [Failure] @yieldreturn [T]

@return [Any, T]

# File lib/remap/mapper/support/api.rb, line 24
def call(input, backtrace: caller, **options, &error)
  unless error
    return call(input, **options) do |failure|
      raise failure.exception(backtrace)
    end
  end

  s0 = State.call(input, options: options, mapper: self)._

  s1 = call!(s0) do |failure|
    return error[failure]
  end

  case s1
  in { value: value }
    value
  in { notices: [] }
    error[s1.failure("No data could be mapped")]
  in { notices: }
    error[Failure.new(failures: notices)]
  end
end
validate?() click to toggle source

@return [Boolean]

@abstract @private

# File lib/remap/mapper/support/api.rb, line 12
def validate?
  raise NotImplementedError, "`validate?` is not implemented for #{self}"
end