unidom-visitor 0.8.2 → 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b97e8e9ee1c305b40713388c2ecf4ac4226a8a86
4
- data.tar.gz: 62a31acdd6556812c362638d67fbeaea2313eb51
3
+ metadata.gz: 01370e102c661bcadb06f064cd2567cf3c45829d
4
+ data.tar.gz: 14fe8bd66d6d7686103d136374e35bfb0cf6804e
5
5
  SHA512:
6
- metadata.gz: fa44c0ad81ac50baa45d2d3865345926c5486720e75bcf06129f5018a818a6165b0c3a38305c45982f434488f145fe4e9becd820f0ba587502284a73cc1139d3
7
- data.tar.gz: 775aca83996d79ff5fb7adfc5e68cb5db676f76af44542dd5b21caaa674a20518819fb03c6ea17edc3cd1b3c65756c4f6be2ca7ba4b6b51d3eb91317a1d0893d
6
+ metadata.gz: b7b131561c9ebf76373240d1a2ea8e38ce45313e57dd7dbbd0861b53de56e667d4931e3ebfac642c5b6a9df380a6de1348f0724f21bbe0cb8b51cdb9501658da
7
+ data.tar.gz: 016015bf45809e5bcfaaf91541e32e4778c0995658701aa89d94f193610bdd74644080f23fae030512d34b473f3760cf5d88d60ddcd6de87bf32cf87c015dd5d
data/README.md CHANGED
@@ -52,3 +52,10 @@ user = Unidom::Visitor::User.create! opened_at: Time.now
52
52
  email = Unidom::Contact::EmailAddress.full_address_is('name@company.com').valid_at.alive.first_or_create! opened_at: Time.now
53
53
  Unidom::Visitor::Identificating.identificate! user, as: email
54
54
  ```
55
+
56
+ ### Recognization model
57
+ ```ruby
58
+ user = Unidom::Visitor::User.create! opened_at: Time.now
59
+ person = Unidom::Party::Person.create! name: 'Tim', opened_at: Time.now
60
+ Unidom::Visitor::Recognization.cognize! user, as: person
61
+ ```
@@ -13,9 +13,26 @@ class Unidom::Visitor::Recognization < ActiveRecord::Base
13
13
  include Unidom::Common::Concerns::ModelExtension
14
14
 
15
15
  def self.cognize(visitor, party, elemental: true, opened_at: Time.now)
16
+ warn "The Unidom::Visitor::Recognization.cognize method is deprecated, and will be removed since unidom-visitor v1.0. Please use the Unidom::Visitor::Recognization.cognize method instead."
16
17
  raise 'Visitor can not be null.' if visitor.blank?
17
18
  raise 'Party can not be null.' if party.blank?
18
19
  recognization = visitor_is(visitor).party_is(party).first_or_create elemental: elemental, opened_at: opened_at
19
20
  end
20
21
 
22
+ def self.cognize!(visitor, as: nil, at: Time.now, primary: false)
23
+ query = visitor_is(visitor).party_is(as).valid_at.alive
24
+ recognization = query.first
25
+ if recognization.present?
26
+ recognization.elemental = primary
27
+ recognization.save!
28
+ recognization
29
+ else
30
+ query.create! elemental: primary, opened_at: at
31
+ end
32
+ end
33
+
34
+ class << self
35
+ deprecate cognize: :cognize!, deprecator: ActiveSupport::Deprecation.new('1.0', 'unidom-visitor')
36
+ end
37
+
21
38
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '0.8.2'.freeze
3
+ VERSION = '0.9'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-visitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-22 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common