Module: Remap::Mapper::API

Included in:
Base, Binary
Defined in:
lib/remap/mapper/support/api.rb

Instance Method Summary collapse

Instance Method Details

#call(input, backtrace: caller, **options) {|| ... } ⇒ Any, T

Parameters:

  • input (Any)
  • backtrace (Array<String>) (defaults to: caller)
  • options (Hash)

Yield Parameters:

Yield Returns:

  • (T)

Returns:

  • (Any, T)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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?Boolean

This method is abstract.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


12
13
14
# File 'lib/remap/mapper/support/api.rb', line 12

def validate?
  raise NotImplementedError, "`validate?` is not implemented for #{self}"
end