Module: GuineaPig

Defined in:
lib/guinea_pig.rb,
lib/guinea_pig/ab_test.rb,
lib/guinea_pig/version.rb,
lib/guinea_pig/experiments.rb

Defined Under Namespace

Modules: Experiments Classes: ABTest, MigrationGenerator

Constant Summary collapse

VERSION =
"0.1.3"

Class Method Summary collapse

Class Method Details

.alternative(experiment, guinea_pig) ⇒ Object



11
12
13
14
15
# File 'lib/guinea_pig.rb', line 11

def self.alternative(experiment, guinea_pig)
  ab_test = get(experiment, guinea_pig)
  ab_test.increment!(:seen_count)
  ab_test.alternative
end

.conversion(experiment, guinea_pig) ⇒ Object



17
18
19
20
# File 'lib/guinea_pig.rb', line 17

def self.conversion(experiment, guinea_pig)
  ab_test = get(experiment, guinea_pig)
  ab_test.conversion!
end

.get(experiment, guinea_pig) ⇒ Object



7
8
9
# File 'lib/guinea_pig.rb', line 7

def self.get(experiment, guinea_pig)
  ::GuineaPig::ABTest.where(:experiment => experiment, :guinea_pig_id => guinea_pig.id, :guinea_pig_type => guinea_pig.class.name).first_or_create
end