Class: Vanity::Adapters::ActiveRecordAdapter::VanityParticipant
- Inherits:
-
VanityRecord
- Object
- ActiveRecord::Base
- VanityRecord
- Vanity::Adapters::ActiveRecordAdapter::VanityParticipant
- Defined in:
- lib/vanity/adapters/active_record_adapter.rb
Overview
Participant model
Class Method Summary collapse
-
.retrieve(experiment, identity, create = true, update_with = nil) ⇒ Object
Finds the participant by experiment and identity.
Methods inherited from VanityRecord
Class Method Details
.retrieve(experiment, identity, create = true, update_with = nil) ⇒ Object
Finds the participant by experiment and identity. If create is true then it will create the participant if not found. If a hash is passed then this will be passed to create if creating, or will be used to update the found participant.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/vanity/adapters/active_record_adapter.rb', line 124 def self.retrieve(experiment, identity, create = true, update_with = nil) record = VanityParticipant.first( :conditions => {:experiment_id => experiment.to_s, :identity => identity}) if record record.update_attributes(update_with) if update_with elsif create record = VanityParticipant.create( {:experiment_id => experiment.to_s, :identity => identity}.merge(update_with || {})) end record end |