Skip to content
Permalink
Browse files

Issue #7: Implement simple API for checking if an installation is par…

…t of a specific experiment

Closes #7: Implement simple API for checking if an installation is part of a specific experiment
  • Loading branch information...
fercarcedo committed Jun 18, 2018
1 parent af80d36 commit 93b2fb9407926a7910b353265667938f2daaea63
Showing with 18 additions and 1 deletion.
  1. +18 −1 fretboard/src/main/java/mozilla/components/service/fretboard/Fretboard.kt
@@ -4,6 +4,8 @@

package mozilla.components.service.fretboard

import android.content.Context

/**
* Entry point of the library
*
@@ -12,10 +14,12 @@ package mozilla.components.service.fretboard
*/
class Fretboard(
private val source: ExperimentSource,
private val storage: ExperimentStorage
private val storage: ExperimentStorage,
regionProvider: RegionProvider? = null
) {
private var experiments: List<Experiment> = listOf()
private var experimentsLoaded: Boolean = false
private val evaluator = ExperimentEvaluator(regionProvider)

/**
* Loads experiments from local storage
@@ -43,4 +47,17 @@ class Fretboard(
// Keep using the local experiments
}
}

/**
* Checks if the user is part of
* the specified experiment
*
* @param context context
* @param descriptor descriptor of the experiment to check
*
* @return true if the user is part of the specified experiment, false otherwise
*/
fun isInExperiment(context: Context, descriptor: ExperimentDescriptor): Boolean {
return evaluator.evaluate(context, descriptor, experiments)
}
}

0 comments on commit 93b2fb9

Please sign in to comment.
You can’t perform that action at this time.