Module: OnRamp
- Extended by:
- OnRamp
- Included in:
- OnRamp
- Defined in:
- lib/on_ramp.rb,
lib/on_ramp/ramp.rb,
lib/on_ramp/bucket.rb,
lib/on_ramp/version.rb,
lib/on_ramp/configuration.rb
Defined Under Namespace
Modules: Bucket, Ramp
Classes: Configuration, InvalidExperimentName
Constant Summary
collapse
- VERSION =
'0.0.1'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.ab_variant(experiment_name:, unique_id:) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/on_ramp.rb', line 15
def ab_variant(experiment_name:, unique_id:)
validate_experiment_name(experiment_name)
variant = if !ramped?(
experiment_name: experiment_name,
unique_id: unique_id
)
nil
else
OnRamp::Bucket.get_variant(
experiment_name: experiment_name.to_s,
unique_id: unique_id
)
end
OnRamp.configuration.ab_variant_callback_function&.call(
experiment_name,
variant,
unique_id
)
variant
end
|
.ramped?(experiment_name:, unique_id:) ⇒ Boolean
10
11
12
13
|
# File 'lib/on_ramp.rb', line 10
def ramped?(experiment_name:, unique_id:)
validate_experiment_name(experiment_name)
OnRamp::Ramp.ramped?(experiment_name.to_s, unique_id)
end
|
.validate_experiment_name(experiment_name) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/on_ramp.rb', line 40
def validate_experiment_name(experiment_name)
return if OnRamp.ab_experiments[experiment_name.to_s]
raise InvalidExperimentName,
"The key does not exist: #{experiment_name}"
end
|
Instance Method Details
#ab_experiments ⇒ Object
15
16
17
|
# File 'lib/on_ramp/configuration.rb', line 15
def ab_experiments
configuration.ab_experiments
end
|
#configuration ⇒ Object
7
8
9
|
# File 'lib/on_ramp/configuration.rb', line 7
def configuration
@configuration ||= Configuration.new
end
|
11
12
13
|
# File 'lib/on_ramp/configuration.rb', line 11
def configure
yield(configuration)
end
|