Sha256: 74f110dfd28fcdec182e8fb6e05bca749a93ff9e4f53b58e013225c9bc8e592c

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

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

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

  self.table_name = 'unidom_identificatings'

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

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

  include Unidom::Common::Concerns::ModelExtension

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

  def self.identificate(visitor, identity, opened_at: Time.now)
    self.visitor_is(visitor).identity_is(identity).valid_at.alive.first_or_create opened_at: opened_at
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unidom-visitor-0.7 app/models/unidom/visitor/identificating.rb
unidom-visitor-0.6 app/models/unidom/visitor/identificating.rb
unidom-visitor-0.5 app/models/unidom/visitor/identificating.rb
unidom-visitor-0.4 app/models/unidom/visitor/identificating.rb