Sha256: 37439efdd4fdf48743cd5d0bc8748aa32d643c7c5e1ee212e3f2ed048b1804a3
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module Split class Trial attr_accessor :experiment attr_accessor :goals def initialize(attrs = {}) self.experiment = attrs[:experiment] if !attrs[:experiment].nil? self.alternative = attrs[:alternative] if !attrs[:alternative].nil? self.goals = attrs[:goals] if !attrs[:goals].nil? end def alternative @alternative ||= if experiment.winner experiment.winner end end def complete! if alternative if self.goals.empty? alternative.increment_completion else self.goals.each {|g| alternative.increment_completion(g)} end end end def choose! choose record! end def record! alternative.increment_participation end def choose self.alternative = experiment.next_alternative end def alternative=(alternative) @alternative = if alternative.kind_of?(Split::Alternative) alternative else self.experiment.alternatives.find{|a| a.name == alternative } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
split-0.6.0 | lib/split/trial.rb |