Sha256: 3229c68c94aff9910a7c5f0240678bef8d322f4f478015d553f6d5a722093c02

Contents?: true

Size: 747 Bytes

Versions: 12

Compression:

Stored size: 747 Bytes

Contents

module Virtus

  # Abstract coercer class
  #
  class Coercer

    # @api private
    attr_reader :primitive, :type

    # @api private
    def initialize(type)
      @type      = type
      @primitive = type.primitive
    end

    # Coerce input value into expected primitive type
    #
    # @param [Object] input
    #
    # @return [Object] coerced input
    #
    # @api public
    def call(input)
      NotImplementedError.new("#{self.class}#call must be implemented")
    end

    # Return if the input value was successfuly coerced
    #
    # @param [Object] input
    #
    # @return [Object] coerced input
    #
    # @api public
    def success?(primitive, input)
      input.kind_of?(primitive)
    end

  end # Coercer

end # Virtus

Version data entries

12 entries across 10 versions & 3 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/virtus-1.0.5/lib/virtus/coercer.rb
virtus-1.0.5 lib/virtus/coercer.rb
virtus-1.0.4 lib/virtus/coercer.rb
virtus-1.0.3 lib/virtus/coercer.rb
virtus-1.0.2 lib/virtus/coercer.rb
virtus-1.0.1 lib/virtus/coercer.rb
virtus-1.0.0 lib/virtus/coercer.rb