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.

Direct Known Subclasses

ActiveRecordAdapter, MockAdapter, MongodbAdapter, RedisAdapter

Instance Method Summary (collapse)

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.



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

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.



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

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

- (Object) ab_assigned(experiment, identity)

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



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

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



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

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.



138
139
140
# File 'lib/vanity/adapters/abstract_adapter.rb', line 138

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.



108
109
110
# File 'lib/vanity/adapters/abstract_adapter.rb', line 108

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

- (Object) ab_seen(experiment, identity, assignment)

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



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

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

- (Object) ab_set_outcome(experiment, alternative = 0)

Sets the outcome of this experiment to a particular alternative.



143
144
145
# File 'lib/vanity/adapters/abstract_adapter.rb', line 143

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



97
98
99
# File 'lib/vanity/adapters/abstract_adapter.rb', line 97

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.



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

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

- (Boolean) active?

Returns true if connected.

Returns:

  • (Boolean)


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.



148
149
150
# File 'lib/vanity/adapters/abstract_adapter.rb', line 148

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

- (Boolean) experiment_persisted?(experiment)

– Experiments –

Returns:

  • (Boolean)


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

def experiment_persisted?(experiment)
  fail "Not implemented"
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.



79
80
81
# File 'lib/vanity/adapters/abstract_adapter.rb', line 79

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.

Returns:

  • (Boolean)


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

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



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

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