Sha256: d1e3cc5a8b8a4f8bb3fde39a4be46d7ea98e671d0fe1d337025f4447f47a371c
Contents?: true
Size: 781 Bytes
Versions: 13
Compression:
Stored size: 781 Bytes
Contents
module FieldTest class Participant attr_reader :type, :id 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 def participant [type, id].compact.join(":") end def where_values if FieldTest.legacy_participants { participant: participant } else { participant_type: type, participant_id: id } end end def self.standardize(participant) Array(participant).compact.map { |v| FieldTest::Participant.new(v) } end end end
Version data entries
13 entries across 13 versions & 1 rubygems