Sha256: 52466ee062596c3bc30dda1cd4fb53013d9e8c5d8f7980f976265c70431aa0ed

Contents?: true

Size: 452 Bytes

Versions: 2

Compression:

Stored size: 452 Bytes

Contents

module Datacaster
  class Transformer < Base
    def initialize(&block)
      raise "Expected block" unless block_given?

      @transform = block
    end

    def cast(object, runtime:)
      result = Runtimes::Base.(runtime, @transform, object)
      if runtime.respond_to?(:will_not_check!)
        runtime.will_not_check!
      end
      Datacaster::ValidResult(result)
    end

    def inspect
      "#<Datacaster::Transformer>"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datacaster-4.1.0 lib/datacaster/transformer.rb
datacaster-4.0.1 lib/datacaster/transformer.rb