unidom-visitor 1.0 → 1.1

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: 2b78681195ec68847b13f4464ff5f5209324413b
4
- data.tar.gz: 184c37314a0cd2baf22b2c3d13bad94c1dd19e46
3
+ metadata.gz: 3282315f8bd1fe0a2f2880d46d5530c86325a0bf
4
+ data.tar.gz: 54927a4887ae4770fbf92313929b5b50828bb38a
5
5
  SHA512:
6
- metadata.gz: 145e2338a7bbba9654e3e905f1248fb369d916823f1e21d89aa4cf60860e99084be3806f324361a4fc08d096c15d3336faf8e05a3d54ee1610c6ca72b22704b9
7
- data.tar.gz: eee33ac2f40db2896822446719118acd50fb8ab5a78a5fc0cb4978ef6b03e4ae307a778858002818e7f4a9b57d2161e6c78573fdccaf9e1fb7a1a9f3e58d80c7
6
+ metadata.gz: 98c604a2ab5e767806c16a26535140d12aeddeebcc67eafa06e07fbd0abc6e5b365c8e9440ac9ec6589165f4e089acdebb023ee9aca4260926f02d9da3887b95
7
+ data.tar.gz: 6d72101039d892581ec4443ab8e62aa435e5947c381dda51a4caa280f09535ccea4d6086c464c686e540bc1f888b367129c751ed7ab3be863a2d77c1aece92f5
data/README.md CHANGED
@@ -71,3 +71,18 @@ user = Unidom::Visitor::User.create! opened_at: Time.now
71
71
  person = Unidom::Party::Person.create! name: 'Tim', opened_at: Time.now
72
72
  Unidom::Visitor::Recognization.cognize! user, as: person
73
73
  ```
74
+
75
+
76
+
77
+ ## Inlcude the Concerns
78
+ ```ruby
79
+ include Unidom::Visitor::Concerns::AsVisitor
80
+ ```
81
+
82
+ ### As Visitor concern
83
+ The As Visitor concern do the following tasks for the includer automatically:
84
+ 1. Define the has_many :identificatings macro as: ``has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor``
85
+ 2. Define the has_many :authenticatings macro as: ``has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor``
86
+ 3. Define the has_many :recognizations macro as: ``has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor``
87
+ 4. Define the .identified_by scope as: ``scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }``
88
+ 5. Define the .sign_up method as: ``sign_up(identity, password: nil, opened_at: Time.now)``
@@ -0,0 +1,21 @@
1
+ module Unidom::Visitor::Concerns::AsVisitor
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor
8
+
9
+ has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor
10
+ #has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'
11
+
12
+ has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor
13
+
14
+ scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }
15
+
16
+ end
17
+
18
+ module ClassMethods
19
+ end
20
+
21
+ end
@@ -4,16 +4,19 @@ class Unidom::Visitor::User < ActiveRecord::Base
4
4
 
5
5
  self.table_name = 'unidom_users'
6
6
 
7
- has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor
7
+ #has_many :identificatings, class_name: 'Unidom::Visitor::Identificating', as: :visitor
8
8
 
9
- has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor
10
- has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'
9
+ #has_many :authenticatings, class_name: 'Unidom::Visitor::Authenticating', as: :visitor
10
+ #has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'
11
11
 
12
- has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor
12
+ #has_many :recognizations, class_name: 'Unidom::Visitor::Recognization', as: :visitor
13
13
 
14
- scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }
14
+ #scope :identified_by, ->(identity) { joins(:identificatings).merge(Unidom::Visitor::Identificating.identity_is identity) }
15
15
 
16
16
  include Unidom::Common::Concerns::ModelExtension
17
+ include Unidom::Visitor::Concerns::AsVisitor
18
+
19
+ has_many :passwords, through: :authenticatings, source: :credential, source_type: 'Unidom::Visitor::Password'
17
20
 
18
21
  def self.sign_up(identity, password: nil, opened_at: Time.now)
19
22
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Visitor
3
- VERSION = '1.0'.freeze
3
+ VERSION = '1.1'.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.0'
4
+ version: '1.1'
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-09-20 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -41,6 +41,7 @@ files:
41
41
  - app/controllers/unidom/visitor/application_controller.rb
42
42
  - app/helpers/unidom/visitor/application_helper.rb
43
43
  - app/models/unidom/visitor/authenticating.rb
44
+ - app/models/unidom/visitor/concerns/as_visitor.rb
44
45
  - app/models/unidom/visitor/guest.rb
45
46
  - app/models/unidom/visitor/identificating.rb
46
47
  - app/models/unidom/visitor/password.rb