Sha256: 8e9b374acf5dfa7e73510f7e1ea428a8e595cb180693b833a754e0d57e09d2c1

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

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

cs__scoped_require 'contrast/utils/object_share'

module Contrast
  module Utils
    # Utility methods for asserting truthy or falsy state of a value expected
    # to equate to a boolean
    class BooleanUtil
      class << self
        # Ruby 2.4 does not nicely compare to nil, so we have to include
        # these wrapper methods. RUBY-179 has the task to update this on
        # EOL of 2.4 support
        def false? config
          return false unless config
          return false if config == true
          return true if config == false

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

        def true? config
          return false unless config
          return false if config == false
          return true if config == true

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-3.9.1 lib/contrast/utils/boolean_util.rb
contrast-agent-3.9.0 lib/contrast/utils/boolean_util.rb
contrast-agent-3.8.5 lib/contrast/utils/boolean_util.rb
contrast-agent-3.8.4 lib/contrast/utils/boolean_util.rb