lib/verdict/storage/base_storage.rb in verdict-0.5.0 vs lib/verdict/storage/base_storage.rb in verdict-0.6.0
- old
+ new
@@ -13,23 +13,25 @@
end
# Should do a fast lookup of an assignment of the subject for the given experiment.
# - Should return nil if not found in store
# - Should return an Assignment instance otherwise.
- def retrieve_assignment(experiment, subject_identifier)
+ def retrieve_assignment(experiment, subject)
+ subject_identifier = experiment.retrieve_subject_identifier(subject)
if value = get(experiment.handle.to_s, "assignment_#{subject_identifier}")
hash = JSON.parse(value)
experiment.subject_assignment(
- subject_identifier,
+ subject,
experiment.group(hash['group']),
Time.xmlschema(hash['created_at'])
)
end
end
# Should remove the subject from storage, so it will be reassigned later.
- def remove_assignment(experiment, subject_identifier)
+ def remove_assignment(experiment, subject)
+ subject_identifier = experiment.retrieve_subject_identifier(subject)
remove(experiment.handle.to_s, "assignment_#{subject_identifier}")
end
# Retrieves the start timestamp of the experiment
def retrieve_start_timestamp(experiment)
@@ -41,10 +43,10 @@
# Stores the timestamp on which the experiment was started
def store_start_timestamp(experiment, timestamp)
set(experiment.handle.to_s, 'started_at', timestamp.utc.strftime('%FT%TZ'))
end
-
+ protected
# Retrieves a key in a given scope from storage.
# - The scope and key are both provided as string.
# - Should return a string value if the key is found in the scope, nil otherwise.
# - Should raise Verdict::StorageError if anything goes wrong.
def get(scope, key)