Sha256: 3cae173dcd6c15d57ae1cc03d9c614a3e3121525e17f2572d466fbf82265e7e7

Contents?: true

Size: 597 Bytes

Versions: 2

Compression:

Stored size: 597 Bytes

Contents

# Class for A-B testing variants. A variant is a set of changes
# to the same element on a page. For example, a variant can be used
# to change the button text, or images displayed, or even more
# complicated behavior
class Caboose::AbVariant < ActiveRecord::Base
  self.table_name = "ab_variants"
  
  has_many :ab_options, -> { order(:id) }, :dependent => :destroy
  has_many :ab_values, :dependent => :destroy
  attr_accessible :name, :analytics_name
  
  def random_option
    return nil if self.ab_options.nil? || self.ab_options.count == 0
    return self.ab_options.sample    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caboose-cms-1.0.2 app/models/caboose/ab_variant.rb
caboose-cms-1.0.1 app/models/caboose/ab_variant.rb