Class: Parameters::Types::Boolean Private

Inherits:
Type show all
Defined in:
lib/parameters/types/boolean.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Class Method Summary collapse

Methods inherited from Type

#<, #<=, #==, #===, #coerce, #to_ruby, to_ruby

Class Method Details

.===(value) ⇒ ::Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Determine if the value is a Boolean.

Parameters:

  • value (true, false)

    The value to inspect.

Returns:

  • (::Boolean)

    Specifies whether the value was a Boolean.

Since:

  • 0.3.0



23
24
25
# File 'lib/parameters/types/boolean.rb', line 23

def self.===(value)
  (value == true) || (value == false)
end

.coerce(value) ⇒ true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerces the value into a Boolean.

Parameters:

  • value (true, false, ::String, ::Symbol, nil)

    The value to coerce.

Returns:

  • (true, false)

    The Boolean value.

Since:

  • 0.3.0



36
37
38
39
40
41
42
43
# File 'lib/parameters/types/boolean.rb', line 36

def self.coerce(value)
  case value
  when FalseClass, 'false', :false
    false
  else
    true
  end
end

.typetrue

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (true)

Since:

  • 0.3.0



10
11
12
# File 'lib/parameters/types/boolean.rb', line 10

def self.type
  true
end