Sha256: d4bba896ec9370aa4d429787e7530930667bb2f587ea47dcd9daef4e33ebd4cc
Contents?: true
Size: 826 Bytes
Versions: 4
Compression:
Stored size: 826 Bytes
Contents
# Recognization 是访问者识别,用于维护访问者和参与者的对应关系。 class Unidom::Visitor::Recognization < Unidom::Visitor::ApplicationRecord self.table_name = 'unidom_recognizations' include Unidom::Common::Concerns::ModelExtension belongs_to :visitor, polymorphic: true belongs_to :party, polymorphic: true scope :visitor_is, ->(visitor) { where visitor: visitor } scope :party_is, ->(party) { where party: party } def self.cognize!(visitor, as: nil, at: Time.now, primary: false) query = visitor_is(visitor).party_is(as).valid_at.alive recognization = query.first if recognization.present? recognization.elemental = primary recognization.save! recognization else query.create! elemental: primary, opened_at: at end end end
Version data entries
4 entries across 4 versions & 1 rubygems