Module: Contrast::Components::ComponentBase::Methods

Defined in:
lib/contrast/components/interface.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#false?(config_param) ⇒ Boolean

use this to determine if the configuration value is literally boolean false or some form of the word ‘false`, regardless of case. It should be used for those values which default to `true` as they should only treat a value explicitly set to `false` as such.

Parameters:

  • config_param (Boolean, String)

    the value to check

Returns:

  • (Boolean)

    should the value be treated as ‘false`



59
60
61
62
63
64
65
# File 'lib/contrast/components/interface.rb', line 59

def false? config_param
  return false if config_param == true
  return true if config_param == false
  return false unless config_param.cs__is_a?(String)

  Contrast::Utils::ObjectShare::FALSE.casecmp?(config_param)
end

#true?(config_param) ⇒ Boolean

use this to determine if the configuration value is literally boolean true or some form of the word ‘true`, regardless of case. It should be used for those values which default to `false` as they should only treat a value explicitly set to `true` as such.

Parameters:

  • config_param (Boolean, String)

    the value to check

Returns:

  • (Boolean)

    should the value be treated as ‘true`



74
75
76
77
78
79
80
# File 'lib/contrast/components/interface.rb', line 74

def true? config_param
  return false if config_param == false
  return true if config_param == true
  return false unless config_param.cs__is_a?(String)

  Contrast::Utils::ObjectShare::TRUE.casecmp?(config_param)
end