unidom-visitor 1.7 → 1.8
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 +9 -7
- data/app/models/unidom/visitor/concerns/as_credential.rb +11 -0
- data/app/models/unidom/visitor/concerns/as_identity.rb +9 -0
- data/app/models/unidom/visitor/concerns/as_party.rb +10 -0
- data/app/models/unidom/visitor/concerns/as_visitor.rb +34 -6
- 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: 1039cdfc9483bce1ae792b1927c290dd1bb1a4fe
|
4
|
+
data.tar.gz: db3e19bc847504447ca25bfdee0099c28d6bc725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37e8ce876225bec3bc119d9f999c9f63f5af41725d5a7788aaaacd7857abd9425639eacc92d298c4c5ec27f9710e42221e971bc4daa3dc372f8f468179d0ffc6
|
7
|
+
data.tar.gz: 05e70ecd150bee453e44dee1198aeb1a9b7d99027af72a78ba6432293fcf53f4cbb4d79d91dafe9da4d6fe1ba5447c52d05364a78fafff3b47fe399ed6ebb2d1
|
data/README.md
CHANGED
@@ -84,6 +84,7 @@ Unidom::Visitor::Recognization.cognize! user, as: person
|
|
84
84
|
include Unidom::Visitor::Concerns::AsVisitor
|
85
85
|
include Unidom::Visitor::Concerns::AsIdentity
|
86
86
|
include Unidom::Visitor::Concerns::AsCredential
|
87
|
+
include Unidom::Visitor::Concerns::AsParty
|
87
88
|
```
|
88
89
|
|
89
90
|
### As Visitor concern
|
@@ -93,25 +94,26 @@ The As Visitor concern do the following tasks for the includer automatically:
|
|
93
94
|
2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
|
94
95
|
3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
|
95
96
|
4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
|
96
|
-
5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
|
97
|
-
6. Define the #is_identificated! method as: ``is_identificated!(as: nil, at: Time.now)``
|
98
|
-
7. Define the #is_authenticated! method as: ``is_authenticated!(through: nil, at: Time.now, flag_code: 'RQRD')``
|
99
|
-
8. Define the #cognize! method as: ``cognize!(it, at: Time.now, primary: true)``
|
97
|
+
5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
|
98
|
+
6. Define the #is_identificated! method as: ``is_identificated!(as: nil, at: Time.now)``
|
99
|
+
7. Define the #is_authenticated! method as: ``is_authenticated!(through: nil, at: Time.now, flag_code: 'RQRD')``
|
100
|
+
8. Define the #cognize! method as: ``cognize!(it, at: Time.now, primary: true)``
|
101
|
+
9. Define the .sign_up! method as: ``sign_up!(it, as: nil, through: nil, at: Time.now, flag_code: 'RQRD', primary: true)``
|
100
102
|
|
101
103
|
### As Identity concern
|
102
104
|
|
103
105
|
The As Identity concern do the following tasks for the includer automatically:
|
104
|
-
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :identity``
|
106
|
+
1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :identity``
|
105
107
|
2. Define the #identificate! method as: ``identificate!(it, at: Time.now)``
|
106
108
|
|
107
109
|
### As Credential concern
|
108
110
|
|
109
111
|
The As Credential concern do the following tasks for the includer automatically:
|
110
|
-
1. Define the has_one :authenticatings macro as: ``has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential``
|
112
|
+
1. Define the has_one :authenticatings macro as: ``has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential``
|
111
113
|
2. Define the #authenticate! method as: ``authenticate!(it, at: Time.now, flag_code: 'RQRD')``
|
112
114
|
|
113
115
|
### As Party concern
|
114
116
|
|
115
117
|
The As Party concern do the following tasks for the includer automatically:
|
116
|
-
1. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party``
|
118
|
+
1. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party``
|
117
119
|
2. Define the #is_cognized! method as: ``is_cognized!(via: nil, at: Time.now, primary: true)``
|
@@ -11,6 +11,17 @@ module Unidom::Visitor::Concerns::AsCredential
|
|
11
11
|
create_authenticating! visitor: it, flag_code: flag_code, opened_at: at
|
12
12
|
end
|
13
13
|
|
14
|
+
=begin
|
15
|
+
def authenticate?(it, at: Time.now, flag_code: 'RQRD')
|
16
|
+
return false if authenticating.blank?
|
17
|
+
result = true
|
18
|
+
result &&= it==authenticating.visitor if it.present?
|
19
|
+
result &&= at<=authenticating.closed_at&&at>=authenticating.opened_at if at.present?
|
20
|
+
result &&= flag_code==authenticating.flag_code if flag_code.present?
|
21
|
+
result
|
22
|
+
end
|
23
|
+
=end
|
24
|
+
|
14
25
|
end
|
15
26
|
|
16
27
|
module ClassMethods
|
@@ -10,6 +10,15 @@ module Unidom::Visitor::Concerns::AsIdentity
|
|
10
10
|
identificatings.create! visitor: it, opened_at: at
|
11
11
|
end
|
12
12
|
|
13
|
+
=begin
|
14
|
+
def identificate?(it, at: Time.now)
|
15
|
+
query = identificatings
|
16
|
+
query = query.visitor_is it if it.present?
|
17
|
+
query = query.valid_at now: at if at.present?
|
18
|
+
query.alive.exists?
|
19
|
+
end
|
20
|
+
=end
|
21
|
+
|
13
22
|
end
|
14
23
|
|
15
24
|
module ClassMethods
|
@@ -10,6 +10,16 @@ module Unidom::Visitor::Concerns::AsParty
|
|
10
10
|
recognizations.create! visitor: via, elemental: primary, opened_at: at
|
11
11
|
end
|
12
12
|
|
13
|
+
=begin
|
14
|
+
def is_cognized?(via: nil, at: Time.now, primary: true)
|
15
|
+
query = recognizations
|
16
|
+
query = query.visitor_is via if via.present?
|
17
|
+
query = query.primary primary unless primary.nil?
|
18
|
+
query = query.valid_at now: at if at.present?
|
19
|
+
query = query.alive.exists?
|
20
|
+
end
|
21
|
+
=end
|
22
|
+
|
13
23
|
end
|
14
24
|
|
15
25
|
module ClassMethods
|
@@ -16,6 +16,15 @@ module Unidom::Visitor::Concerns::AsVisitor
|
|
16
16
|
identificatings.create! identity: as, opened_at: at
|
17
17
|
end
|
18
18
|
|
19
|
+
=begin
|
20
|
+
def is_identificated?(as: nil, at: Time.now)
|
21
|
+
query = identificatings
|
22
|
+
query = query.identity_is as if as.present?
|
23
|
+
query = query.valid_at now: at if at.present?
|
24
|
+
query.alive.exists?
|
25
|
+
end
|
26
|
+
=end
|
27
|
+
|
19
28
|
def is_authenticated!(through: nil, at: Time.now, flag_code: 'RQRD')
|
20
29
|
if through.authenticating.present?
|
21
30
|
through.authenticating
|
@@ -24,22 +33,41 @@ module Unidom::Visitor::Concerns::AsVisitor
|
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
36
|
+
=begin
|
37
|
+
def is_authenticated?(through: nil, at: Time.now, flag_code: 'RQRD')
|
38
|
+
query = authenticatings
|
39
|
+
query = query.credential_is through if through.present?
|
40
|
+
query = query.flag_coded_as flag_code if flag_code.present?
|
41
|
+
query = query.valid_at now: at if at.present?
|
42
|
+
query.alive.exists?
|
43
|
+
end
|
44
|
+
=end
|
45
|
+
|
27
46
|
def cognize!(it, at: Time.now, primary: true)
|
28
47
|
recognizations.create! party: it, elemental: primary, opened_at: at
|
29
48
|
end
|
30
49
|
|
50
|
+
=begin
|
51
|
+
def cognize?(it, at: Time.now, primary: true)
|
52
|
+
query = recognizations
|
53
|
+
query = query.party_is it if it.present?
|
54
|
+
query = query.primary primary unless primary.nil?
|
55
|
+
query = query.valid_at now: at if at.present?
|
56
|
+
query.alive.exists?
|
57
|
+
end
|
58
|
+
=end
|
59
|
+
|
31
60
|
end
|
32
61
|
|
33
62
|
module ClassMethods
|
34
63
|
|
35
|
-
=begin
|
36
64
|
def sign_up!(it, as: nil, through: nil, at: Time.now, flag_code: 'RQRD', primary: true)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
65
|
+
user = create! opened_at: at
|
66
|
+
user.cognize! it, primary: true, at: at
|
67
|
+
user.is_identificated! as: as, at: at
|
68
|
+
user.is_authenticated! through: through, at: at
|
69
|
+
user
|
41
70
|
end
|
42
|
-
=end
|
43
71
|
|
44
72
|
end
|
45
73
|
|
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: '1.
|
4
|
+
version: '1.8'
|
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-10-
|
11
|
+
date: 2016-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|