Sha256: 9e7b44c34bdab90084263902b0666cdd158c76a78c93f0cb390a4cb930324881

Contents?: true

Size: 720 Bytes

Versions: 8

Compression:

Stored size: 720 Bytes

Contents

# Identificating 是身份关联,存储身份(identity)和访问者(visitor)之间的关联关系。

class Unidom::Visitor::Identificating < ActiveRecord::Base

  self.table_name = 'unidom_identificatings'

  include Unidom::Common::Concerns::ModelExtension

  belongs_to :identity, polymorphic: true
  belongs_to :visitor,  polymorphic: true

  scope :identity_is, ->(identity) { where identity: identity }
  scope :visitor_is,  ->(visitor)  { where visitor:  visitor  }

  def self.find_identity(visitor)
    visitor_is(visitor).first.try :identity
  end

  def self.identificate!(visitor, as: nil, at: Time.now)
    self.visitor_is(visitor).identity_is(as).valid_at.alive.first_or_create! opened_at: at
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
unidom-visitor-1.11 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.10 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.9 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.8 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.7 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.6 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.5 app/models/unidom/visitor/identificating.rb
unidom-visitor-1.4 app/models/unidom/visitor/identificating.rb