unidom-party 1.5 → 1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f27f34bb20b80585520c786cfb813e9218788f57
|
4
|
+
data.tar.gz: 7785f0f54cd08dbb8cbcd56ce83853537ab70d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b9a3349edf2e3d6975beaa2896fa0ffc84f206488b9bd73a57c3db589fb07c8ef8a6b7e2e4c6afc0d9a531fe0221362a03e205749fd348403da2a3567998ee0
|
7
|
+
data.tar.gz: c55824e0f21a5e5a45c1c4fb36aa6dae604a6f51eb0f7a36e6efbb0a835752de73f324c9d1c90971c656f4b3377deea4987b2468c3c6349f86048d70d8673824
|
data/README.md
CHANGED
@@ -87,9 +87,12 @@ The As Target Party concern do the following tasks for the includer automaticall
|
|
87
87
|
### As Collaboration concern
|
88
88
|
|
89
89
|
The As Collaboration concern do the following tasks for the includer automatically:
|
90
|
-
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaboration``
|
90
|
+
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaboration``
|
91
|
+
2. Define the #is_collaborated! method as: ``is_collaborated!(by: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
91
92
|
|
92
93
|
### As Collaborator concern
|
93
94
|
|
94
95
|
The As Collaborator concern do the following tasks for the includer automatically:
|
95
|
-
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaborator``
|
96
|
+
1. Define the has_many :collaboratings macro as: ``has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaborator``
|
97
|
+
2. Define the #collaborate! method as: ``collaborate!(on: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)``
|
98
|
+
|
@@ -6,6 +6,28 @@ module Unidom::Party::Concerns::AsCollaboration
|
|
6
6
|
|
7
7
|
has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaboration
|
8
8
|
|
9
|
+
def is_collaborated!(by: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)
|
10
|
+
collaborating = collaboratings.collaborated_by(by).role_coded_as(as).valid_at(now: at).alive.first
|
11
|
+
if collaborating.present?
|
12
|
+
collaborating.attributes = { name: name, priority: priority, grade: grade }
|
13
|
+
collaborating.save!
|
14
|
+
else
|
15
|
+
collaborating = collaboratings.create! collaborator: by, role_code: as, name: name, priority: priority, grade: grade, opened_at: at
|
16
|
+
end
|
17
|
+
collaborating
|
18
|
+
end
|
19
|
+
|
20
|
+
=begin
|
21
|
+
def is_collaborated?(by: nil, as: nil, at: Time.now, priority: nil, grade: nil)
|
22
|
+
query = collaboratings
|
23
|
+
query = query.collaborated_by by if by.present?
|
24
|
+
query = query.role_coded_as as if as.present?
|
25
|
+
query = query.priority_is priority if priority.present?
|
26
|
+
query = query.grade_is grade if grade.present?
|
27
|
+
query.valid_at(now: at).alive.exists?
|
28
|
+
end
|
29
|
+
=end
|
30
|
+
|
9
31
|
end
|
10
32
|
|
11
33
|
module ClassMethods
|
@@ -6,6 +6,28 @@ module Unidom::Party::Concerns::AsCollaborator
|
|
6
6
|
|
7
7
|
has_many :collaboratings, class_name: 'Unidom::Party::Collaborating', as: :collaborator
|
8
8
|
|
9
|
+
def collaborate!(on: nil, as: nil, at: Time.now, name: nil, priority: 0, grade: 0)
|
10
|
+
collaborating = collaboratings.collaboration_is(on).role_coded_as(as).valid_at(now: at).alive.first
|
11
|
+
if collaborating.present?
|
12
|
+
collaborating.attributes = { name: name, priority: priority, grade: grade }
|
13
|
+
collaborating.save!
|
14
|
+
else
|
15
|
+
collaborating = collaboratings.create! collaboration: on, role_code: as, name: name, priority: priority, grade: grade, opened_at: at
|
16
|
+
end
|
17
|
+
collaborating
|
18
|
+
end
|
19
|
+
|
20
|
+
=begin
|
21
|
+
def collaborate?(on: nil, as: nil, at: Time.now, priority: nil, grade: nil)
|
22
|
+
query = collaboratings
|
23
|
+
query = query.collaboration_is on if on.present?
|
24
|
+
query = query.role_coded_as as if as.present?
|
25
|
+
query = query.priority_is priority if priority.present?
|
26
|
+
query = query.grade_is grade if grade.present?
|
27
|
+
query.valid_at(now: at).alive.exists?
|
28
|
+
end
|
29
|
+
=end
|
30
|
+
|
9
31
|
end
|
10
32
|
|
11
33
|
module ClassMethods
|
data/lib/unidom/party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.6'
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|