Class: Vanity::Adapters::AbstractAdapter
- Inherits:
-
Object
- Object
- Vanity::Adapters::AbstractAdapter
- Defined in:
- lib/vanity/adapters/abstract_adapter.rb
Overview
Base class for all adapters. Adapters wrap underlying connection to a datastore and implement an API that Vanity can use to store/access metrics, experiments, etc.
Direct Known Subclasses
ActiveRecordAdapter, MockAdapter, MongodbAdapter, RedisAdapter
Instance Method Summary (collapse)
-
- (Object) ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false)
Records a conversion in this experiment for the given alternative.
-
- (Object) ab_add_participant(experiment, alternative, identity)
Records a participant in this experiment for the given alternative.
-
- (Object) ab_counts(experiment, alternative)
Returns counts for given A/B experiment and alternative (by index).
-
- (Object) ab_get_outcome(experiment)
Returns the outcome of this expriment (if set), the index of a particular alternative.
-
- (Object) ab_not_showing(experiment, identity)
Cancels previously set association between identity and alternative.
-
- (Object) ab_set_outcome(experiment, alternative = 0)
Sets the outcome of this experiment to a particular alternative.
-
- (Object) ab_show(experiment, identity, alternative)
Pick particular alternative (by index) to show to this particular participant (by identity).
-
- (Object) ab_showing(experiment, identity)
Indicates which alternative to show to this participant.
-
- (Boolean) active?
Returns true if connected.
-
- (Object) destroy_experiment(experiment)
Deletes all information about this experiment.
-
- (Object) destroy_metric(metric)
Deletes all information about this metric.
-
- (Object) disconnect!
Close connection, release any resources.
-
- (Object) flushdb
Empty the database.
-
- (Object) get_experiment_created_at(experiment)
Return when experiment was created.
-
- (Object) get_metric_last_update_at(metric)
Return when metric was last updated.
-
- (Boolean) is_experiment_completed?(experiment)
Returns true if experiment completed.
-
- (Object) metric_track(metric, timestamp, identity, values)
Track metric data.
-
- (Object) metric_values(metric, from, to)
Returns all the metric values between from and to time instances (inclusive).
-
- (Object) reconnect!
Close and reopen connection.
-
- (Object) set_experiment_created_at(experiment, time)
Store when experiment was created (do not write over existing value).
Instance Method Details
- (Object) ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false)
Records a conversion in this experiment for the given alternative. Associates a value with the conversion (default to 1). If implicit is true, add particpant if not already recorded for this experiment. If implicit is false (default), only add conversion is participant previously recorded as participating in this experiment.
118 119 120 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 118 def ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false) fail "Not implemented" end |
- (Object) ab_add_participant(experiment, alternative, identity)
Records a participant in this experiment for the given alternative.
109 110 111 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 109 def ab_add_participant(experiment, alternative, identity) fail "Not implemented" end |
- (Object) ab_counts(experiment, alternative)
Returns counts for given A/B experiment and alternative (by index). Returns hash with values for the keys :participants, :converted and :conversions.
87 88 89 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 87 def ab_counts(experiment, alternative) fail "Not implemented" end |
- (Object) ab_get_outcome(experiment)
Returns the outcome of this expriment (if set), the index of a particular alternative.
124 125 126 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 124 def ab_get_outcome(experiment) fail "Not implemented" end |
- (Object) ab_not_showing(experiment, identity)
Cancels previously set association between identity and alternative. See #ab_show.
104 105 106 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 104 def ab_not_showing(experiment, identity) fail "Not implemented" end |
- (Object) ab_set_outcome(experiment, alternative = 0)
Sets the outcome of this experiment to a particular alternative.
129 130 131 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 129 def ab_set_outcome(experiment, alternative = 0) fail "Not implemented" end |
- (Object) ab_show(experiment, identity, alternative)
Pick particular alternative (by index) to show to this particular participant (by identity).
93 94 95 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 93 def ab_show(experiment, identity, alternative) fail "Not implemented" end |
- (Object) ab_showing(experiment, identity)
Indicates which alternative to show to this participant. See #ab_show.
98 99 100 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 98 def ab_showing(experiment, identity) fail "Not implemented" end |
- (Boolean) active?
Returns true if connected.
26 27 28 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 26 def active? false end |
- (Object) destroy_experiment(experiment)
Deletes all information about this experiment.
134 135 136 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 134 def destroy_experiment(experiment) fail "Not implemented" end |
- (Object) destroy_metric(metric)
Deletes all information about this metric.
62 63 64 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 62 def destroy_metric(metric) fail "Not implemented" end |
- (Object) disconnect!
Close connection, release any resources.
31 32 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 31 def disconnect! end |
- (Object) flushdb
Empty the database. This is used during tests.
39 40 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 39 def flushdb end |
- (Object) get_experiment_created_at(experiment)
Return when experiment was created.
75 76 77 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 75 def get_experiment_created_at(experiment) fail "Not implemented" end |
- (Object) get_metric_last_update_at(metric)
Return when metric was last updated.
46 47 48 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 46 def get_metric_last_update_at(metric) fail "Not implemented" end |
- (Boolean) is_experiment_completed?(experiment)
Returns true if experiment completed.
80 81 82 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 80 def is_experiment_completed?(experiment) fail "Not implemented" end |
- (Object) metric_track(metric, timestamp, identity, values)
Track metric data.
51 52 53 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 51 def metric_track(metric, , identity, values) fail "Not implemented" end |
- (Object) metric_values(metric, from, to)
Returns all the metric values between from and to time instances (inclusive). Returns pairs of date and total count for that date.
57 58 59 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 57 def metric_values(metric, from, to) fail "Not implemented" end |
- (Object) reconnect!
Close and reopen connection.
35 36 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 35 def reconnect! end |
- (Object) set_experiment_created_at(experiment, time)
Store when experiment was created (do not write over existing value).
70 71 72 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 70 def set_experiment_created_at(experiment, time) fail "Not implemented" end |