All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gu.featureswitching.FeatureSwitching.scala Maven / Gradle / Ivy

package com.gu.featureswitching

case class FeatureSwitch(key: String, title: String, default: Boolean)

trait FeatureSwitching extends FeatureSwitchingEnablingStrategy with FeatureSwitchingOverrideStrategy {
  val features: List[FeatureSwitch]

  def featureIsActive(feature: FeatureSwitch): Boolean = {
    featureIsOverridden(feature) orElse featureIsEnabled(feature) getOrElse feature.default
  }
}

trait FeatureSwitchingEnablingStrategy {
  def featureIsEnabled(feature: FeatureSwitch): Option[Boolean]
  def featureSetEnabled(feature: FeatureSwitch, enabled: Boolean)
  def featureResetEnabled(feature: FeatureSwitch)
}

trait FeatureSwitchingOverrideStrategy {
  def featureIsOverridden(feature: FeatureSwitch): Option[Boolean]
  def featureSetOverride(feature: FeatureSwitch, overridden: Boolean)
  def featureResetOverride(feature: FeatureSwitch)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy