Sha256: fac700b1d732919bd54fa2ab44d0fa713e908eb12389126ca76b357db3948037

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Components
    # All components should inherit from this,
    # whether Interfaces, InstanceMethods or ClassMethods.
    module ComponentBase
      # 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.
      #
      # @param config_param [Boolean,String] the value to check
      # @return [Boolean] should the value be treated as `false`
      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)

        config_param.downcase == Contrast::Utils::ObjectShare::FALSE
      end

      # 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.
      #
      # @param config_param [Boolean,String] the value to check
      # @return [Boolean] should the value be treated as `true`
      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)

        config_param.downcase == Contrast::Utils::ObjectShare::TRUE
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-4.13.1 lib/contrast/components/base.rb
contrast-agent-4.13.0 lib/contrast/components/base.rb
contrast-agent-4.12.0 lib/contrast/components/base.rb
contrast-agent-4.11.0 lib/contrast/components/base.rb
contrast-agent-4.10.0 lib/contrast/components/base.rb