unidom-party 0.5 → 0.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 +4 -4
- data/README.md +6 -0
- data/app/models/unidom/party/government_agency.rb +1 -0
- data/app/models/unidom/party/party_relation.rb +10 -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: dfbbfddcce3cf5f2ac61009b0044986d8be8305e
|
4
|
+
data.tar.gz: b84b5f3b54e6cc33f605a8393e3d65f32e7f48ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 741275bc47493859668d28ec11b687256ab77023ddf36287f5d25425009d5f03cdbb7d05fabc29baab0c66fc0e0ca623a8ed81b9c09bb10b28664a34c78e1430
|
7
|
+
data.tar.gz: 31469de07a8d38269969b19b5062a94eb364aa5e807e4aca675b6d8f24ea4a40504ae5e56f3ad8e6dc36381db2cd92f56876bb0fbaf27de30212cab6422fbad8
|
data/README.md
CHANGED
@@ -29,4 +29,10 @@ person.target_party_relations
|
|
29
29
|
|
30
30
|
government_agency = Unidom::Party::GovernmentAgency.valid_at.alive.first
|
31
31
|
government_agency.supervision_region
|
32
|
+
|
33
|
+
relation = Unidom::Party::PartyRelation.relate company, person, linkage_code: 'EMPL', grade: 0, priority: 0, opened_at: Time.now, attributes: {}
|
34
|
+
# The company employs the person
|
35
|
+
|
36
|
+
Unidom::Party::PartyRelation.source_party_is(company).target_party_is(person).valid_at.alive
|
37
|
+
# Find all relationships from the company & the person, like employment
|
32
38
|
```
|
@@ -10,6 +10,16 @@ class Unidom::Party::PartyRelation < ActiveRecord::Base
|
|
10
10
|
belongs_to :source_party, polymorphic: true
|
11
11
|
belongs_to :target_party, polymorphic: true
|
12
12
|
|
13
|
+
scope :source_party_is, ->(source_party) { where source_party: source_party }
|
14
|
+
scope :target_party_is, ->(target_party) { where target_party: target_party }
|
15
|
+
|
13
16
|
include Unidom::Common::Concerns::ModelExtension
|
14
17
|
|
18
|
+
def self.relate(source_party, target_party, linkage_code: 'FRND', grade: 0, priority: 0, opened_at: Time.now, attributes: {})
|
19
|
+
relation = source_party_is(source_party).target_party_is(target_party).linkage_coded_as(linkage_code).first_or_initialize grade: grade, priority: priority, opened_at: opened_at
|
20
|
+
relation.assign_attributes attributes
|
21
|
+
relation.save
|
22
|
+
relation
|
23
|
+
end
|
24
|
+
|
15
25
|
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: '0.
|
4
|
+
version: '0.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-03-
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|