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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da6a352066a2a8cbd63b3ac270db33368977474a
4
- data.tar.gz: 6c1cf67ae25275213333777c8ed84b1a702386be
3
+ metadata.gz: 3265651cea821f567d8e9ecd4f0375eae55206b3
4
+ data.tar.gz: 5b21ba81d356d0249622de5854e23b4dd4ecc7b9
5
5
  SHA512:
6
- metadata.gz: 49762cc91346d650622ebf88e8c802113fcf5f3515c6b9aa9aa742383c417e6fd7c1db6f0d7e094b284d482e66ac17575437553627a6108ba25026ab794b44bb
7
- data.tar.gz: 3898dd908599567741c0964b31517bce7827b85177496102b0e4b3df90d7c04cfdabda04f0bde92ba84b32b7dce83d154c9a052c1c104d6b70e2440fa5517dda
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Party
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-party
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-01 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common