Sha256: 548db8cffab456cfeed54ab05e818c8a73fddf3a01ae8bc7237e27c14c408405
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 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].nil? ? [] : attrs[:goals] end def alternative @alternative ||= if experiment.has_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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
split-1.0.0 | lib/split/trial.rb |
split-0.8.0 | lib/split/trial.rb |
split-0.7.3 | lib/split/trial.rb |
split-0.7.2 | lib/split/trial.rb |
split-0.7.1 | lib/split/trial.rb |