Sha256: 30672e7c8f8c1fb638ef140b461238b9c5ef53dda1907fcd6d23953e9a659cec
Contents?: true
Size: 829 Bytes
Versions: 1
Compression:
Stored size: 829 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-visitor-1.12.3 | app/models/unidom/visitor/recognization.rb |