Class: Vanity::Adapters::AbstractAdapter

Inherits:
Object
  • Object
show all
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.

Instance Method Summary collapse

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.



113
114
115
# File 'lib/vanity/adapters/abstract_adapter.rb', line 113

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.



104
105
106
# File 'lib/vanity/adapters/abstract_adapter.rb', line 104

def ab_add_participant(experiment, alternative, identity)
  fail "Not implemented"
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.



82
83
84
# File 'lib/vanity/adapters/abstract_adapter.rb', line 82

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.



119
120
121
# File 'lib/vanity/adapters/abstract_adapter.rb', line 119

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.



99
100
101
# File 'lib/vanity/adapters/abstract_adapter.rb', line 99

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.



124
125
126
# File 'lib/vanity/adapters/abstract_adapter.rb', line 124

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).



88
89
90
# File 'lib/vanity/adapters/abstract_adapter.rb', line 88

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.



93
94
95
# File 'lib/vanity/adapters/abstract_adapter.rb', line 93

def ab_showing(experiment, identity)
  fail "Not implemented"
end

#active?Boolean

Returns true if connected.

Returns:

  • (Boolean)


21
22
23
# File 'lib/vanity/adapters/abstract_adapter.rb', line 21

def active?
  false
end

#destroy_experiment(experiment) ⇒ Object

Deletes all information about this experiment.



129
130
131
# File 'lib/vanity/adapters/abstract_adapter.rb', line 129

def destroy_experiment(experiment)
  fail "Not implemented"
end

#destroy_metric(metric) ⇒ Object

Deletes all information about this metric.



57
58
59
# File 'lib/vanity/adapters/abstract_adapter.rb', line 57

def destroy_metric(metric)
  fail "Not implemented"
end

#disconnect!Object

Close connection, release any resources.



26
27
# File 'lib/vanity/adapters/abstract_adapter.rb', line 26

def disconnect!
end

#flushdbObject

Empty the database. This is used during tests.



34
35
# File 'lib/vanity/adapters/abstract_adapter.rb', line 34

def flushdb
end

#get_experiment_created_at(experiment) ⇒ Object

Return when experiment was created.



70
71
72
# File 'lib/vanity/adapters/abstract_adapter.rb', line 70

def get_experiment_created_at(experiment)
  fail "Not implemented"
end

#get_metric_last_update_at(metric) ⇒ Object

Return when metric was last updated.



41
42
43
# File 'lib/vanity/adapters/abstract_adapter.rb', line 41

def get_metric_last_update_at(metric)
  fail "Not implemented"
end

#is_experiment_completed?(experiment) ⇒ Boolean

Returns true if experiment completed.

Returns:

  • (Boolean)


75
76
77
# File 'lib/vanity/adapters/abstract_adapter.rb', line 75

def is_experiment_completed?(experiment)
  fail "Not implemented"
end

#metric_track(metric, timestamp, identity, values) ⇒ Object

Track metric data.



46
47
48
# File 'lib/vanity/adapters/abstract_adapter.rb', line 46

def metric_track(metric, timestamp, 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.



52
53
54
# File 'lib/vanity/adapters/abstract_adapter.rb', line 52

def metric_values(metric, from, to)
  fail "Not implemented"
end

#reconnect!Object

Close and reopen connection.



30
31
# File 'lib/vanity/adapters/abstract_adapter.rb', line 30

def reconnect!
end

#set_experiment_created_at(experiment, time) ⇒ Object

Store when experiment was created (do not write over existing value).



65
66
67
# File 'lib/vanity/adapters/abstract_adapter.rb', line 65

def set_experiment_created_at(experiment, time)
  fail "Not implemented"
end