lib/field_test/helpers.rb in field_test-0.3.2 vs lib/field_test/helpers.rb in field_test-0.4.0
- old
+ new
@@ -20,14 +20,19 @@
options[:ip] = request.remote_ip
options[:user_agent] = request.user_agent
end
- # cache results for request
- @field_test_cache ||= {}
-
# don't update variant when passed via params
- @field_test_cache[experiment] ||= params_variant || exp.variant(participants, options)
+ if params_variant
+ params_variant
+ else
+ # cache results for request
+ # TODO possibly remove in 0.4.0
+ cache_key = [exp.id, participants.map(&:where_values), options.slice(:variant, :exclude)]
+ @field_test_cache ||= {}
+ @field_test_cache[cache_key] ||= exp.variant(participants, options)
+ end
end
def field_test_converted(experiment, **options)
exp = FieldTest::Experiment.find(experiment)