Class: Restspec::Schema::Types::BooleanType

Inherits:
BasicType
  • Object
show all
Defined in:
lib/restspec/schema/types/boolean_type.rb

Instance Method Summary collapse

Methods inherited from BasicType

#initialize, #of, #to_s, #totally_valid?, #|

Constructor Details

This class inherits a constructor from Restspec::Schema::Types::BasicType

Instance Method Details

#example_for(attribute) ⇒ true, false

Generates an example boolean.

Parameters:

Returns:

  • (true, false)

    One of true and false, randomly.


7
8
9
# File 'lib/restspec/schema/types/boolean_type.rb', line 7

def example_for(attribute)
  [true, false].sample
end

#valid?(attribute, value) ⇒ true, false

Validates is the value is a boolean.

Parameters:

Returns:

  • (true, false)

    If the value is one of true and false.


17
18
19
# File 'lib/restspec/schema/types/boolean_type.rb', line 17

def valid?(attribute, value)
  [true, false].include?(value)
end