Sha256: d6828c2283b7cdb5c64352f3262312c4ecbf4368a247711c5f5dcbad3aaa8b9a

Contents?: true

Size: 664 Bytes

Versions: 11

Compression:

Stored size: 664 Bytes

Contents

module Restspec::Schema::Types
  class BooleanType < BasicType
    # Generates an example boolean.
    #
    # @param attribute [Restspec::Schema::Attribute] the atribute of the schema.
    # @return [true, false] One of `true` and `false`, randomly.
    def example_for(attribute)
      [true, false].sample
    end

    # Validates is the value is a boolean.
    #
    # @param attribute [Restspec::Schema::Attribute] the atribute of the schema.
    # @param value [Object] the value of the attribute.
    #
    # @return [true, false] If the value is one of true and false.
    def valid?(attribute, value)
      [true, false].include?(value)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restspec-0.3.2 lib/restspec/schema/types/boolean_type.rb
restspec-0.3.1 lib/restspec/schema/types/boolean_type.rb
restspec-0.3.0 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.6 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.5 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.4 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.3 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.2 lib/restspec/schema/types/boolean_type.rb
restspec-0.2.1 lib/restspec/schema/types/boolean_type.rb
restspec-0.2 lib/restspec/schema/types/boolean_type.rb
restspec-0.1 lib/restspec/schema/types/boolean_type.rb