unidom-party 1.3 → 1.4
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 +2 -0
- data/app/models/unidom/party/collaborating.rb +13 -0
- data/lib/unidom/party/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: 3265651cea821f567d8e9ecd4f0375eae55206b3
|
4
|
+
data.tar.gz: 5b21ba81d356d0249622de5854e23b4dd4ecc7b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e4e72807cd3cc3778527d40496c9573b69019eea9d76f7e5a6d373f4cf173539493fdfa62dbd3485172b645ef384535d5476ec13d485f589d63efdb2e327fdb
|
7
|
+
data.tar.gz: 343170ed2c9fbb2332e1fc8280998a8bd5dfbd06c4df95ef4f8b196a80ea2d9e7314315a82f1a95a4bf3a6239138dfab9f00d10f34fef4e3555197fb045c6aad
|
data/README.md
CHANGED
@@ -42,6 +42,8 @@ Unidom::Party::PartyRelation.source_party_is(company).target_party_is(person).va
|
|
42
42
|
# Find all relationships from the company & the person, like employment
|
43
43
|
|
44
44
|
Unidom::Party::Collaborating.create! collaboration: project, collaborator: person, role_code: 'PJMG', name: 'Project Manager'
|
45
|
+
# or the following source code do the same thing:
|
46
|
+
Unidom::Party::Collaborating.collaborate! collaboration: project, collaborator: person, role_code: 'PJMG', name: 'Project Manager', opened_at: Time.now, priority: 1, grade: 1, description: nil, instruction: nil
|
45
47
|
```
|
46
48
|
|
47
49
|
|
@@ -14,4 +14,17 @@ class Unidom::Party::Collaborating < ActiveRecord::Base
|
|
14
14
|
scope :collaboration_is, ->(collaboration) { where collaboration: collaboration }
|
15
15
|
scope :collaborated_by, ->(collaborator) { where collaborator: collaborator }
|
16
16
|
|
17
|
+
def self.collaborate!(collaboration: nil, collaborator: nil, name: collaborator.try(:name), role_code: nil, priority: 1, grade: 1, description: nil, instruction: nil, opened_at: Time.now)
|
18
|
+
query = collaboration_is(collaboration).collaborated_by(collaborator).role_coded_as(role_code).valid_at(now: opened_at).alive
|
19
|
+
attributes = { name: name, priority: priority, grade: grade, description: description, instruction: instruction }
|
20
|
+
collaborating = query.first_or_initialize attributes
|
21
|
+
if collaborating.new_record?
|
22
|
+
collaborating.opened_at = opened_at
|
23
|
+
else
|
24
|
+
collaborating.attributes = attributes
|
25
|
+
end
|
26
|
+
collaborating.save!
|
27
|
+
collaborating
|
28
|
+
end
|
29
|
+
|
17
30
|
end
|
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.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-
|
11
|
+
date: 2016-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|