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.


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

def ab_add_conversion(_experiment, _alternative, _identity, _count = 1, _implicit = false)
  raise "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)
  raise "Not implemented"
end

#ab_assigned(_experiment, _identity) ⇒ Object

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


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

def ab_assigned(_experiment, _identity)
  raise "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)
  raise "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)
  raise "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)
  raise "Not implemented"
end

#ab_seen(_experiment, _identity, _assignment) ⇒ Object

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


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

def ab_seen(_experiment, _identity, _assignment)
  raise "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)
  raise "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)
  raise "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)
  raise "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.


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

def destroy_experiment(_experiment)
  raise "Not implemented"
end

#destroy_metric(_metric) ⇒ Object

Deletes all information about this metric.


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

def destroy_metric(_metric)
  raise "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)

49
50
51
# File 'lib/vanity/adapters/abstract_adapter.rb', line 49

def experiment_persisted?(_experiment)
  raise "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.


59
60
61
# File 'lib/vanity/adapters/abstract_adapter.rb', line 59

def get_experiment_created_at(_experiment)
  raise "Not implemented"
end

#get_metric_last_update_at(_metric) ⇒ Object

Return when metric was last updated.


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

def get_metric_last_update_at(_metric)
  raise "Not implemented"
end

#is_experiment_completed?(_experiment) ⇒ Boolean

Returns true if experiment completed.

Returns:

  • (Boolean)

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

def is_experiment_completed?(_experiment) # rubocop:todo Naming/PredicateName
  raise "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)

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

def is_experiment_enabled?(_experiment) # rubocop:todo Naming/PredicateName
  raise "Not implemented"
end

#metric_track(_metric, _timestamp, _identity, _values) ⇒ Object

Track metric data.


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

def metric_track(_metric, _timestamp, _identity, _values)
  raise "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.


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

def metric_values(_metric, _from, _to)
  raise "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).


54
55
56
# File 'lib/vanity/adapters/abstract_adapter.rb', line 54

def set_experiment_created_at(_experiment, _time)
  raise "Not implemented"
end

#set_experiment_enabled(_experiment, _enabled) ⇒ Object

Store whether an experiment is enabled or not


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

def set_experiment_enabled(_experiment, _enabled)
  raise "Not implemented"
end