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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97b432b57919bab9692e6d5951d89fac33f088a3
4
- data.tar.gz: 3b71730e437d33d32f8172db2b8219fbb518091d
3
+ metadata.gz: dfbbfddcce3cf5f2ac61009b0044986d8be8305e
4
+ data.tar.gz: b84b5f3b54e6cc33f605a8393e3d65f32e7f48ab
5
5
  SHA512:
6
- metadata.gz: c6febf5cda3542fc747dbfd622b25740f9e19f7f5637540f1b72658e0f269ef3eff84b6b54894ddc7933ad205dd91564604c0e89f41c5eb523a04ab7de7c2fe1
7
- data.tar.gz: 2b48dcf14617991d81368cf5a0a7276b4fcd556f228d4270d1d519d846db9b85694a8671a679e119396d43f77b5a4834b8373613504f8ebb649e98cc6d0b0349
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
  ```
@@ -1,4 +1,5 @@
1
1
  # Government Agency 是政府机构。
2
+ # function_code 是行政职能代码: PLST: Police Station 公安局, PLSS: Police Sub-Station 派出所
2
3
  class Unidom::Party::GovernmentAgency < ActiveRecord::Base
3
4
 
4
5
  self.table_name = 'unidom_government_agencies'
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Party
3
- VERSION = '0.5'.freeze
3
+ VERSION = '0.6'.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: '0.5'
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-22 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common