Class: Vanity::Adapters::ActiveRecordAdapter::VanityExperiment

Inherits:
VanityRecord
  • Object
show all
Defined in:
lib/vanity/adapters/active_record_adapter.rb

Overview

Experiment model

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from VanityRecord

needs_attr_accessible?, rails_agnostic_find_or_create_by

Class Method Details

.retrieve(experiment) ⇒ Object

Finds or creates the experiment


78
79
80
# File 'lib/vanity/adapters/active_record_adapter.rb', line 78

def self.retrieve(experiment)
  rails_agnostic_find_or_create_by(:experiment_id, experiment.to_s)
end

Instance Method Details

#increment_conversion(alternative, count = 1) ⇒ Object


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

def increment_conversion(alternative, count = 1)
  record = vanity_conversions.rails_agnostic_find_or_create_by(:alternative, alternative)
  record.class.update_counters(record.id, conversions: count)
end