Sha256: 21f11d91d08af578b2a7729daf523f46af8e55164f11c20424f2adbc4a511692
Contents?: true
Size: 822 Bytes
Versions: 1
Compression:
Stored size: 822 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(participants, options = {}) Array(options[:participant] || participants).compact.map { |v| FieldTest::Participant.new(v) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
field_test-0.3.0 | lib/field_test/participant.rb |