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.



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

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.



106
107
108
# File 'lib/vanity/adapters/abstract_adapter.rb', line 106

def ab_add_participant(experiment, alternative, identity)
  fail "Not implemented"
end

#ab_assigned(experiment, identity) ⇒ Object

Determines what alternative a participant has already been given, if any



116
117
118
# File 'lib/vanity/adapters/abstract_adapter.rb', line 116

def ab_assigned(experiment, 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.



84
85
86
# File 'lib/vanity/adapters/abstract_adapter.rb', line 84

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.



131
132
133
# File 'lib/vanity/adapters/abstract_adapter.rb', line 131

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.



101
102
103
# File 'lib/vanity/adapters/abstract_adapter.rb', line 101

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

#ab_seen(experiment, identity, assignment) ⇒ Object

Determines if a participant already has seen this alternative in this experiment.



111
112
113
# File 'lib/vanity/adapters/abstract_adapter.rb', line 111

def ab_seen(experiment, identity, assignment)
  fail "Not implemented"
end

#ab_set_outcome(experiment, alternative = 0) ⇒ Object

Sets the outcome of this experiment to a particular alternative.



136
137
138
# File 'lib/vanity/adapters/abstract_adapter.rb', line 136

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



90
91
92
# File 'lib/vanity/adapters/abstract_adapter.rb', line 90

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.



95
96
97
# File 'lib/vanity/adapters/abstract_adapter.rb', line 95

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

#active?Boolean

Returns true if connected.

Returns:

  • (Boolean)


8
9
10
# File 'lib/vanity/adapters/abstract_adapter.rb', line 8

def active?
  false
end

#destroy_experiment(experiment) ⇒ Object

Deletes all information about this experiment.



141
142
143
# File 'lib/vanity/adapters/abstract_adapter.rb', line 141

def destroy_experiment(experiment)
  fail "Not implemented"
end

#destroy_metric(metric) ⇒ Object

Deletes all information about this metric.



44
45
46
# File 'lib/vanity/adapters/abstract_adapter.rb', line 44

def destroy_metric(metric)
  fail "Not implemented"
end

#disconnect!Object

Close connection, release any resources.



13
14
# File 'lib/vanity/adapters/abstract_adapter.rb', line 13

def disconnect!
end

#experiment_persisted?(experiment) ⇒ Boolean

– Experiments –

Returns:

  • (Boolean)


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

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

#flushdbObject

Empty the database. This is used during tests.



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

def flushdb
end

#get_experiment_created_at(experiment) ⇒ Object

Return when experiment was created.



61
62
63
# File 'lib/vanity/adapters/abstract_adapter.rb', line 61

def get_experiment_created_at(experiment)
  fail "Not implemented"
end

#get_metric_last_update_at(metric) ⇒ Object

Return when metric was last updated.



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

def get_metric_last_update_at(metric)
  fail "Not implemented"
end

#is_experiment_completed?(experiment) ⇒ Boolean

Returns true if experiment completed.

Returns:

  • (Boolean)


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

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

#is_experiment_enabled?(experiment) ⇒ Boolean

Returns true if experiment is enabled, the default (Vanity.configuration.experiments_start_enabled) is true. (*except for mock_adapter, where default is true for testing)

Returns:

  • (Boolean)


77
78
79
# File 'lib/vanity/adapters/abstract_adapter.rb', line 77

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

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

Track metric data.



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

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.



39
40
41
# File 'lib/vanity/adapters/abstract_adapter.rb', line 39

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

#reconnect!Object

Close and reopen connection.



17
18
# File 'lib/vanity/adapters/abstract_adapter.rb', line 17

def reconnect!
end

#set_experiment_created_at(experiment, time) ⇒ Object

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



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

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

#set_experiment_enabled(experiment, enabled) ⇒ Object

Store whether an experiment is enabled or not



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

def set_experiment_enabled(experiment, enabled)
  fail "Not implemented"
end