Sha256: 6388822c6be172a5c338c9b29c17753a8172a9b8553918a01695bc6fa017673d

Contents?: true

Size: 1.66 KB

Versions: 2

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)

        Contrast::Utils::ObjectShare::FALSE.casecmp?(config_param)
      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)

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-4.9.1 lib/contrast/components/base.rb
contrast-agent-4.9.0 lib/contrast/components/base.rb