Sha256: 96e6bc04a6fe2b3e6d8abad2cb0c3dfb254dfe833894d9afe91aacc519300df6

Contents?: true

Size: 432 Bytes

Versions: 2

Compression:

Stored size: 432 Bytes

Contents

module Rasti
  module Types
    module Castable

      def cast(value)
        return nil if value.nil?

        if valid? value
          transform! value
        else
          raise CastError.new self, value
        end
      end

      private

      def transform!(value)
        transform value
      rescue CompoundError => ex
        raise ex
      rescue
        raise CastError.new self, value
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasti-types-2.0.1 lib/rasti/types/castable.rb
rasti-types-2.0.0 lib/rasti/types/castable.rb