Class: ABTest
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ABTest
- Defined in:
- lib/a_b/model/a_b_test.rb
Instance Method Summary collapse
Instance Method Details
#control ⇒ Object
12 13 14 |
# File 'lib/a_b/model/a_b_test.rb', line 12 def control self.variants.find_by_control true end |
#sorted_variants ⇒ Object
16 17 18 |
# File 'lib/a_b/model/a_b_test.rb', line 16 def sorted_variants self.variants.find(:all, :order => 'control desc, conversions / visitors desc, visitors desc') end |
#variant_names ⇒ Object
20 21 22 23 24 |
# File 'lib/a_b/model/a_b_test.rb', line 20 def variant_names names = self.variants.collect &:name names.delete self.control.name names.unshift self.control.name end |
#variants=(names) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/a_b/model/a_b_test.rb', line 26 def variants=(names) names = names.gsub(/[^,\w]/, '').split(',').uniq current_names = variants.collect(&:name).uniq @control = names.first @new_variant_names = names - current_names @removed_variant_names = current_names - names end |