lib/eeny-meeny/models/experiment.rb in eeny-meeny-2.0.0 vs lib/eeny-meeny/models/experiment.rb in eeny-meeny-2.1.0

- old
+ new

@@ -34,9 +34,13 @@ return true if @end_at.nil? && (@start_at && (now > @start_at)) # specified start - open-ended return true if @start_at.nil? && (@end_at && (now < @end_at)) # unspecified start - specified end !!((@start_at && (now > @start_at)) && (@end_at && (now < @end_at))) # specified start and end end + def find_variation(variation_id) + @variations.detect { |v| v.id.to_s == variation_id.to_s } + end + def pick_variation Hash[ @variations.map do |variation| [variation, variation.weight] end