Sha256: 54157c8854a9db1c6ae85942cbf42a6ed43e059b040b170a2efe3b57ea7f50e8

Contents?: true

Size: 759 Bytes

Versions: 8

Compression:

Stored size: 759 Bytes

Contents

# Recognization 是访问者识别,用于维护访问者和参与者的对应关系。

class Unidom::Visitor::Recognization < ActiveRecord::Base

  self.table_name = 'unidom_recognizations'

  belongs_to :visitor, polymorphic: true
  belongs_to :party,   polymorphic: true

  scope :visitor_is,  ->(visitor) { where visitor: visitor }
  scope :party_is,    ->(party)   { where party:   party   }

  include Unidom::Common::Concerns::ModelExtension

  def self.cognize(visitor, party, elemental: true, opened_at: Time.now)
    raise 'Visitor can not be null.' if visitor.blank?
    raise 'Party can not be null.'   if party.blank?
    recognization = visitor_is(visitor).party_is(party).first_or_create elemental: elemental, opened_at: opened_at
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
unidom-visitor-0.8.2 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.8.1 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.8 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.7 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.6 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.5 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.4 app/models/unidom/visitor/recognization.rb
unidom-visitor-0.3 app/models/unidom/visitor/recognization.rb