unidom-party 1.0.2 → 1.1

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: 6d50553d9b3064b90a32e6e90f3cbdc860e2b19e
4
- data.tar.gz: 06d4921d34bc0b874571d1bc94acb84daf373744
3
+ metadata.gz: 7d44dcf01377fa6797a750edb94b2c8182e98479
4
+ data.tar.gz: b4c7fa3d7e60b442962b8cbd3dc0ec86bcf19d06
5
5
  SHA512:
6
- metadata.gz: 616f7a06b7108b9a85e6a12506c5caf680fa3241dbe3127b87ad0204e79f348ae4ab20fb1f22a1d6b034762c74d7a2b38bfa738c378f215a649a646ffd91925e
7
- data.tar.gz: dc78da090f43d62616c1b8402fae80664abd73719c805b20f9ea670a7f69a1872f0f52f99b23a2ff2f1ed7313b6d0453c95d0d90f7deb0cf92d40975379df944
6
+ metadata.gz: a6923e9a51e04950edca947f0e8a4dd8166537fd6d7cfb14d46c33a4c1e5b00e84ffd693c2cfb90d6c06285c7f8b7cd60d72d890a7fd2a4f25be77585bdc748f
7
+ data.tar.gz: 83e799e3dd925119559f84b5a701da8908cbdaf9c1f01a188f6ba44bc09a44613fdb056069a5178f55ce61bbdcf062963eab78fc70c0ff2274d147b1ac7682c4
data/README.md CHANGED
@@ -41,3 +41,19 @@ relation = Unidom::Party::PartyRelation.relate! source_party: company, target_pa
41
41
  Unidom::Party::PartyRelation.source_party_is(company).target_party_is(person).valid_at.alive
42
42
  # Find all relationships from the company & the person, like employment
43
43
  ```
44
+
45
+
46
+
47
+ ## Inlcude the Concerns
48
+ ```ruby
49
+ include Unidom::Party::Concerns::AsSourceParty
50
+ include Unidom::Party::Concerns::AsTargetParty
51
+ ```
52
+
53
+ ### As Source Party concern
54
+ The As Source Party concern do the following tasks for the includer automatically:
55
+ 1. Define the has_many :target_party_relations macro as: ``has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party``
56
+
57
+ ### As Target Party concern
58
+ The As Target Party concern do the following tasks for the includer automatically:
59
+ 1. Define the has_many :source_party_relations macro as: ``has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party``
@@ -5,10 +5,9 @@ class Unidom::Party::Company < ActiveRecord::Base
5
5
  self.table_name = 'unidom_companies'
6
6
 
7
7
  include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Party::Concerns::AsSourceParty
9
+ include Unidom::Party::Concerns::AsTargetParty
8
10
 
9
11
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
10
12
 
11
- has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
12
- has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
13
-
14
13
  end
@@ -0,0 +1,14 @@
1
+ module Unidom::Party::Concerns::AsSourceParty
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
8
+
9
+ end
10
+
11
+ module ClassMethods
12
+ end
13
+
14
+ end
@@ -0,0 +1,14 @@
1
+ module Unidom::Party::Concerns::AsTargetParty
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
8
+
9
+ end
10
+
11
+ module ClassMethods
12
+ end
13
+
14
+ end
@@ -5,14 +5,13 @@ class Unidom::Party::GovernmentAgency < ActiveRecord::Base
5
5
  self.table_name = 'unidom_government_agencies'
6
6
 
7
7
  include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Party::Concerns::AsSourceParty
9
+ include Unidom::Party::Concerns::AsTargetParty
8
10
 
9
11
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
10
12
 
11
13
  belongs_to :supervision_region, polymorphic: true
12
14
 
13
- has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
14
- has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
15
-
16
15
  scope :supervision_region_is, ->(region) { where supervision_region: region }
17
16
 
18
17
  end
@@ -5,10 +5,9 @@ class Unidom::Party::Person < ActiveRecord::Base
5
5
  self.table_name = 'unidom_people'
6
6
 
7
7
  include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Party::Concerns::AsSourceParty
9
+ include Unidom::Party::Concerns::AsTargetParty
8
10
 
9
11
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
10
12
 
11
- has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
12
- has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
13
-
14
13
  end
@@ -5,10 +5,9 @@ class Unidom::Party::Shop < ActiveRecord::Base
5
5
  self.table_name = 'unidom_shops'
6
6
 
7
7
  include Unidom::Common::Concerns::ModelExtension
8
+ include Unidom::Party::Concerns::AsSourceParty
9
+ include Unidom::Party::Concerns::AsTargetParty
8
10
 
9
11
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
10
12
 
11
- has_many :source_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :target_party
12
- has_many :target_party_relations, class_name: 'Unidom::Party::PartyRelation', as: :source_party
13
-
14
13
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Party
3
- VERSION = '1.0.2'.freeze
3
+ VERSION = '1.1'.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.0.2
4
+ version: '1.1'
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-08-26 00:00:00.000000000 Z
11
+ date: 2016-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -41,6 +41,8 @@ files:
41
41
  - app/controllers/unidom/party/application_controller.rb
42
42
  - app/helpers/unidom/party/application_helper.rb
43
43
  - app/models/unidom/party/company.rb
44
+ - app/models/unidom/party/concerns/as_source_party.rb
45
+ - app/models/unidom/party/concerns/as_target_party.rb
44
46
  - app/models/unidom/party/government_agency.rb
45
47
  - app/models/unidom/party/party_relation.rb
46
48
  - app/models/unidom/party/person.rb