unidom-party 1.0.2 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/app/models/unidom/party/company.rb +2 -3
- data/app/models/unidom/party/concerns/as_source_party.rb +14 -0
- data/app/models/unidom/party/concerns/as_target_party.rb +14 -0
- data/app/models/unidom/party/government_agency.rb +2 -3
- data/app/models/unidom/party/person.rb +2 -3
- data/app/models/unidom/party/shop.rb +2 -3
- data/lib/unidom/party/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d44dcf01377fa6797a750edb94b2c8182e98479
|
4
|
+
data.tar.gz: b4c7fa3d7e60b442962b8cbd3dc0ec86bcf19d06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.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-
|
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
|