Class: 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
-
#ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false) ⇒ Object
Records a conversion in this experiment for the given alternative.
-
#ab_add_participant(experiment, alternative, identity) ⇒ Object
Records a participant in this experiment for the given alternative.
-
#ab_chosen(experiment, identity) ⇒ Object
Indicates which alternative has been picked for this participant.
-
#ab_counts(experiment, alternative) ⇒ Object
Returns counts for given A/B experiment and alternative (by index).
-
#ab_get_outcome(experiment) ⇒ Object
Returns the outcome of this expriment (if set), the index of a particular alternative.
-
#ab_not_showing(experiment, identity) ⇒ Object
Cancels previously set association between identity and alternative.
-
#ab_set_outcome(experiment, alternative = 0) ⇒ Object
Sets the outcome of this experiment to a particular alternative.
-
#ab_show(experiment, identity, alternative) ⇒ Object
Pick particular alternative (by index) to show to this particular participant (by identity).
-
#ab_showing(experiment, identity) ⇒ Object
Indicates which alternative to show to this participant.
-
#active? ⇒ Boolean
Returns true if connected.
-
#destroy_experiment(experiment) ⇒ Object
Deletes all information about this experiment.
-
#destroy_metric(metric) ⇒ Object
Deletes all information about this metric.
-
#disconnect! ⇒ Object
Close connection, release any resources.
-
#flushdb ⇒ Object
Empty the database.
-
#get_experiment_created_at(experiment) ⇒ Object
Return when experiment was created.
-
#get_metric_last_update_at(metric) ⇒ Object
Return when metric was last updated.
-
#is_experiment_completed?(experiment) ⇒ Boolean
Returns true if experiment completed.
-
#metric_track(metric, timestamp, identity, values) ⇒ Object
Track metric data.
-
#metric_values(metric, from, to) ⇒ Object
Returns all the metric values between from and to time instances (inclusive).
-
#reconnect! ⇒ Object
Close and reopen connection.
-
#set_experiment_created_at(experiment, time) ⇒ Object
Store when experiment was created (do not write over existing value).
Instance Method Details
#ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false) ⇒ Object
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.
123 124 125 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 123 def ab_add_conversion(experiment, alternative, identity, count = 1, implicit = false) fail "Not implemented" end |
#ab_add_participant(experiment, alternative, identity) ⇒ Object
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 |
#ab_chosen(experiment, identity) ⇒ Object
Indicates which alternative has been picked for this participant. See #ab_add_participant.
114 115 116 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 114 def ab_chosen(experiment, identity) false # TODO: default to false for now; should add to each adapter end |
#ab_counts(experiment, alternative) ⇒ Object
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 |
#ab_get_outcome(experiment) ⇒ Object
Returns the outcome of this expriment (if set), the index of a particular alternative.
129 130 131 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 129 def ab_get_outcome(experiment) fail "Not implemented" end |
#ab_not_showing(experiment, identity) ⇒ Object
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 |
#ab_set_outcome(experiment, alternative = 0) ⇒ Object
Sets the outcome of this experiment to a particular alternative.
134 135 136 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 134 def ab_set_outcome(experiment, alternative = 0) fail "Not implemented" end |
#ab_show(experiment, identity, alternative) ⇒ Object
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 |
#ab_showing(experiment, identity) ⇒ Object
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 |
#active? ⇒ Boolean
Returns true if connected.
26 27 28 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 26 def active? false end |
#destroy_experiment(experiment) ⇒ Object
Deletes all information about this experiment.
139 140 141 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 139 def destroy_experiment(experiment) fail "Not implemented" end |
#destroy_metric(metric) ⇒ Object
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 |
#disconnect! ⇒ Object
Close connection, release any resources.
31 32 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 31 def disconnect! end |
#flushdb ⇒ Object
Empty the database. This is used during tests.
39 40 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 39 def flushdb end |
#get_experiment_created_at(experiment) ⇒ Object
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 |
#get_metric_last_update_at(metric) ⇒ Object
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 |
#is_experiment_completed?(experiment) ⇒ Boolean
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 |
#metric_track(metric, timestamp, identity, values) ⇒ Object
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 |
#metric_values(metric, from, to) ⇒ Object
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 |
#reconnect! ⇒ Object
Close and reopen connection.
35 36 |
# File 'lib/vanity/adapters/abstract_adapter.rb', line 35 def reconnect! end |
#set_experiment_created_at(experiment, time) ⇒ Object
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 |