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 +4 -4
- data/README.md +7 -0
- data/app/models/unidom/visitor/recognization.rb +17 -0
- data/lib/unidom/visitor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01370e102c661bcadb06f064cd2567cf3c45829d
|
4
|
+
data.tar.gz: 14fe8bd66d6d7686103d136374e35bfb0cf6804e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
11
|
+
date: 2016-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|