unidom-visitor 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8d773962937ec0d9982d0d06a3a60a20d60f564
4
- data.tar.gz: 9962fce0d00f6eb63f8d66b85806a8c35e3adcf2
3
+ metadata.gz: 2cde4122ad81c5d0e66fc600f565ea91b273ca39
4
+ data.tar.gz: 5e535fe360ef4f311127a32a078e28ef1c0799cc
5
5
  SHA512:
6
- metadata.gz: 1ceb13ad71b2014f99b451c4124656bf241f71f2f2a2d779f61804fef5e4fe54db40db83002dd5fb1dd0c5acba8be9069baa2692940498df65fea7e43f5ce0c8
7
- data.tar.gz: 44a9af0960256f06835c34439e1f53983a163ee3c8bf0f46d2948c61a74f60f5289cba5224664fafeab8ee23e9ba6210c00511eca0fafa94994895bb49e79859
6
+ metadata.gz: f1e9fdaf5aed17e45f2b762773fa7f022b39ac4f6a9369e5003f8123705b4a859d8de700c89793f62ddffcb4354068048d8d8b3a5bff9da554e42b58e7d4d6a4
7
+ data.tar.gz: 4f43d718974b39f3f512f8fefb5c415d946a52b38997e26380feb932a69c1e4c4ffb6785f71364061f7d2a239a114f138b92f95b2e5a2fd5dc89038168e2dc69
data/README.md CHANGED
@@ -53,6 +53,7 @@ end
53
53
  ```
54
54
 
55
55
  ### Authenticating model
56
+
56
57
  ```ruby
57
58
  user = Unidom::Visitor::User.create! opened_at: Time.now
58
59
  password = Unidom::Visitor::Password.create! clear_text: 'password', opened_at: Time.now
@@ -60,6 +61,7 @@ Unidom::Visitor::Authenticating.authenticate! user, with: password
60
61
  ```
61
62
 
62
63
  ### Identificating model
64
+
63
65
  ```ruby
64
66
  user = Unidom::Visitor::User.create! opened_at: Time.now
65
67
  email = Unidom::Contact::EmailAddress.full_address_is('name@company.com').valid_at.alive.first_or_create! opened_at: Time.now
@@ -67,6 +69,7 @@ Unidom::Visitor::Identificating.identificate! user, as: email
67
69
  ```
68
70
 
69
71
  ### Recognization model
72
+
70
73
  ```ruby
71
74
  user = Unidom::Visitor::User.create! opened_at: Time.now
72
75
  person = Unidom::Party::Person.create! name: 'Tim', opened_at: Time.now
@@ -76,6 +79,7 @@ Unidom::Visitor::Recognization.cognize! user, as: person
76
79
 
77
80
 
78
81
  ## Inlcude the Concerns
82
+
79
83
  ```ruby
80
84
  include Unidom::Visitor::Concerns::AsVisitor
81
85
  include Unidom::Visitor::Concerns::AsIdentity
@@ -83,17 +87,25 @@ include Unidom::Visitor::Concerns::AsCredential
83
87
  ```
84
88
 
85
89
  ### As Visitor concern
90
+
86
91
  The As Visitor concern do the following tasks for the includer automatically:
87
- 1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor``
88
- 2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
89
- 3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
90
- 4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
92
+ 1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor``
93
+ 2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
94
+ 3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
95
+ 4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
91
96
  5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
92
97
 
93
98
  ### As Identity concern
99
+
94
100
  The As Identity concern do the following tasks for the includer automatically:
95
101
  1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :identity``
96
102
 
97
103
  ### As Credential concern
104
+
98
105
  The As Credential concern do the following tasks for the includer automatically:
99
106
  1. Define the has_one :authenticatings macro as: ``has_one :authenticating, class_name: 'Unidom::Visitor::Authenticating', as: :credential``
107
+
108
+ ### As Party concern
109
+
110
+ The As Party concern do the following tasks for the includer automatically:
111
+ 1. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party``
@@ -0,0 +1,14 @@
1
+ module Unidom::Visitor::Concerns::AsParty
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :party
8
+
9
+ end
10
+
11
+ module ClassMethods
12
+ end
13
+
14
+ end
@@ -4,14 +4,14 @@ class Unidom::Visitor::Identificating < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_identificatings'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
7
9
  belongs_to :identity, polymorphic: true
8
10
  belongs_to :visitor, polymorphic: true
9
11
 
10
12
  scope :identity_is, ->(identity) { where identity: identity }
11
13
  scope :visitor_is, ->(visitor) { where visitor: visitor }
12
14
 
13
- include Unidom::Common::Concerns::ModelExtension
14
-
15
15
  def self.find_identity(visitor)
16
16
  visitor_is(visitor).first.try :identity
17
17
  end
@@ -4,14 +4,14 @@ class Unidom::Visitor::Recognization < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_recognizations'
6
6
 
7
+ include Unidom::Common::Concerns::ModelExtension
8
+
7
9
  belongs_to :visitor, polymorphic: true
8
10
  belongs_to :party, polymorphic: true
9
11
 
10
12
  scope :visitor_is, ->(visitor) { where visitor: visitor }
11
13
  scope :party_is, ->(party) { where party: party }
12
14
 
13
- include Unidom::Common::Concerns::ModelExtension
14
-
15
15
  def self.cognize!(visitor, as: nil, at: Time.now, primary: false)
16
16
  query = visitor_is(visitor).party_is(as).valid_at.alive
17
17
  recognization = query.first
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '1.3'.freeze
3
+ VERSION = '1.4'.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: '1.3'
4
+ version: '1.4'
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-04 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -43,6 +43,7 @@ files:
43
43
  - app/models/unidom/visitor/authenticating.rb
44
44
  - app/models/unidom/visitor/concerns/as_credential.rb
45
45
  - app/models/unidom/visitor/concerns/as_identity.rb
46
+ - app/models/unidom/visitor/concerns/as_party.rb
46
47
  - app/models/unidom/visitor/concerns/as_visitor.rb
47
48
  - app/models/unidom/visitor/guest.rb
48
49
  - app/models/unidom/visitor/identificating.rb