class FieldTest::Participant

Attributes

id[R]
type[R]

Public Class Methods

new(object) click to toggle source
# File lib/field_test/participant.rb, line 5
def initialize(object)
  if object.is_a?(FieldTest::Participant)
    @type = object.type
    @id = object.id
  elsif object.respond_to?(:model_name)
    @type = object.model_name.name
    @id = object.id.to_s
  else
    @id = object.to_s
  end
end
standardize(participant) click to toggle source
# File lib/field_test/participant.rb, line 34
def self.standardize(participant)
  Array(participant).compact.map { |v| FieldTest::Participant.new(v) }
end

Public Instance Methods

participant() click to toggle source
# File lib/field_test/participant.rb, line 17
def participant
  [type, id].compact.join(":")
end
where_values() click to toggle source
# File lib/field_test/participant.rb, line 21
def where_values
  if FieldTest.legacy_participants
    {
      participant: participant
    }
  else
    {
      participant_type: type,
      participant_id: id
    }
  end
end