Sha256: 4916d37492ee7bc83ee8403bfcdd8d798fd123230337c190f21daf6375876489

Contents?: true

Size: 590 Bytes

Versions: 2

Compression:

Stored size: 590 Bytes

Contents

module PactBroker
  class FeatureToggle
    def self.enabled?(feature, ignore_env)
      if ignore_env
        feature_in_env_var?(feature)
      else
        not_production? || feature_in_env_var?(feature)
      end
    end

    def self.not_production?
      ENV["RACK_ENV"] != "production"
    end

    def self.feature_in_env_var?(feature)
      (features =~ /\b#{feature}\b/i) != nil
    end

    def self.features
      ENV["PACT_BROKER_FEATURES"] || ""
    end
  end

  def self.feature_enabled?(feature, ignore_env = false)
    FeatureToggle.enabled?(feature, ignore_env)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-2.81.0 lib/pact_broker/feature_toggle.rb
pact_broker-2.80.0 lib/pact_broker/feature_toggle.rb