Sha256: 170b3fda76ee33a7be80a7183b4d2bd1cb3b2c5d9f289b88de67a374bb69ef33

Contents?: true

Size: 522 Bytes

Versions: 1

Compression:

Stored size: 522 Bytes

Contents

module Inspector
  module Constraints
    class Valid
      include Constraint

      def initialize(*args)
        if args.length == 1
          @use_custom_type = true
          @type = args.first
        end
      end

      def validate_as(value)
        return @type if @use_custom_type
        value.class
      end

      def validator
        :validity
      end

      def to_s
        "validate"
      end

      def inspect
        "#<valid%{type}>" % { :type => " #{@type}".rstrip }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
object-inspector-0.1.0 lib/inspector/constraints/valid.rb