Class: PactBroker::FeatureToggle

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/feature_toggle.rb

Class Method Summary collapse

Class Method Details

.enabled?(feature, ignore_env) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/pact_broker/feature_toggle.rb', line 5

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

.feature_in_env_var?(feature) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pact_broker/feature_toggle.rb', line 17

def self.feature_in_env_var?(feature)
  PactBroker.configuration.features[feature.to_s.downcase.to_sym] == true
end

.not_production?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pact_broker/feature_toggle.rb', line 13

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