Sha256: e4703dad998cd69b18fae19ded00904581396409770ecf6da8defdbaa4688eac

Contents?: true

Size: 397 Bytes

Versions: 2

Compression:

Stored size: 397 Bytes

Contents

module Jschematic
  module Attributes
    class Disallow < Type
      # disallow inverts the type attribute, so it succeeds if type fails
      def accepts?(instance)
        inverted = begin
          super
          false
        rescue ValidationError
          true
        end
        inverted || fail_validation!("instance not to be of type '#{type}'", instance)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jschematic-0.1.0 lib/jschematic/attributes/disallow.rb
jschematic-0.0.9 lib/jschematic/attributes/disallow.rb