Sha256: 11d53f97929ff1b3db8814c711dc4186f255bf8a27b403b351622d4ff2a0bc33

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

module Compel
  module Coercion

    class Type

      attr_accessor :value,
                    :options

      def self.coerce(value, options)
        new(value, options).coerce
      end

      def initialize(value, options = {})
        @value = value
        @options = options
      end

      def coerce
        result = coerce_value

        # There are some special cases that
        # we need to build a custom error
        if result.is_a?(Result)
          return result
        end

        Coercion::Result.new(result, value, self.class)
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
compel-0.3.4 lib/compel/coercion/types/type.rb