Sha256: a014364c062f7c0df81d3bada5d6f7af0b4c777fd3f2505482e0c339bf2692b8

Contents?: true

Size: 328 Bytes

Versions: 4

Compression:

Stored size: 328 Bytes

Contents

module Restspec::Schema::Types
  class OneOfType < BasicType
    def example_for(attribute)
      elements.sample
    end

    def valid?(attribute, value)
      elements.include?(value)
    end

    def to_s
      "OneOfType(#{elements})"
    end

    private

    def elements
      options.fetch(:elements)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
restspec-0.0.4 lib/restspec/schema/types/one_of_type.rb
restspec-0.0.3 lib/restspec/schema/types/one_of_type.rb
restspec-0.0.2 lib/restspec/schema/types/one_of_type.rb
restspec-0.0.1 lib/restspec/schema/types/one_of_type.rb