unidom-position 1.1 → 1.2
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 +18 -1
- data/app/models/unidom/position/concerns/as_inferior_post.rb +12 -0
- data/app/models/unidom/position/concerns/as_superior_post.rb +12 -0
- data/app/models/unidom/position/post.rb +2 -6
- data/app/models/unidom/position/post_reporting_structure.rb +2 -2
- data/lib/unidom/position/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b99b9647a75604a07d27ba14e061db245dbeb4e9
|
4
|
+
data.tar.gz: abac026ed73cd646d380c6e2b92cf14aab54eda6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed6e5b1df0b221d3f20963e04aecada1ed2c795f023107e4adf2ea501f77516e74096a86c7eea9fa00fc4a136352d72228c08267996583262f3aeb0e3ed71860
|
7
|
+
data.tar.gz: 63d9dc98150ab98e4401e5c26a56accd0cc4031e593f1b4df13a5932195b345470db54452e64e8e36b992cfc86413bb14d70218ece062ac1f972a00cd61582b4
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ gem 'unidom-position'
|
|
19
19
|
```shell
|
20
20
|
rake db:migrate
|
21
21
|
```
|
22
|
-
The migration versions start with
|
22
|
+
The migration versions start with 200402.
|
23
23
|
|
24
24
|
## Call the Model
|
25
25
|
```ruby
|
@@ -41,3 +41,20 @@ Unidom::Position::PostReportingStructure.report!(superior_post: chief_programmer
|
|
41
41
|
```shell
|
42
42
|
bundle exec rake unidom:position:occupation:import file=/data.csv from_date=2009-11-01 thru_date=2015-10-01 scheme_id= scheme_type=
|
43
43
|
```
|
44
|
+
|
45
|
+
## Include the Concerns
|
46
|
+
The Post model already includes the following concerns:
|
47
|
+
```ruby
|
48
|
+
include Unidom::Position::Concerns::AsInferiorPost
|
49
|
+
include Unidom::Position::Concerns::AsSuperiorPost
|
50
|
+
```
|
51
|
+
|
52
|
+
### As Inferior Post
|
53
|
+
The As Inferior Post concern do the following tasks for the includer automatically:
|
54
|
+
1. Define the has_many :superior_post_reporting_structures macro as: ``has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :inferior_post, foreign_key: :inferior_post_id``
|
55
|
+
2. Define the has_many :superior_posts macro as: ``has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post``
|
56
|
+
|
57
|
+
### As Superior Post
|
58
|
+
The As Superior Post concern do the following tasks for the includer automatically:
|
59
|
+
1. Define the has_many :inferior_post_reporting_structures macro as: ``has_many :inferior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :superior_post, foreign_key: :superior_post_id``
|
60
|
+
2. Define the has_many :inferior_posts macro as: ``has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post``
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Unidom::Position::Concerns::AsInferiorPost
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
self.included do |includer|
|
6
|
+
|
7
|
+
has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :inferior_post, foreign_key: :inferior_post_id
|
8
|
+
has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Unidom::Position::Concerns::AsSuperiorPost
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
self.included do |includer|
|
6
|
+
|
7
|
+
has_many :inferior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :superior_post, foreign_key: :superior_post_id
|
8
|
+
has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -5,16 +5,12 @@ class Unidom::Position::Post < ActiveRecord::Base
|
|
5
5
|
self.table_name = 'unidom_posts'
|
6
6
|
|
7
7
|
include Unidom::Common::Concerns::ModelExtension
|
8
|
+
include Unidom::Position::Concerns::AsInferiorPost
|
9
|
+
include Unidom::Position::Concerns::AsSuperiorPost
|
8
10
|
|
9
11
|
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
10
12
|
|
11
13
|
belongs_to :organization, polymorphic: true
|
12
14
|
belongs_to :position, class_name: 'Unidom::Position::Position'
|
13
15
|
|
14
|
-
has_many :inferior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', foreign_key: :superior_post_id, source: :superior_post
|
15
|
-
has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', foreign_key: :inferior_post_id, source: :inferior_post
|
16
|
-
|
17
|
-
has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post
|
18
|
-
has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post
|
19
|
-
|
20
16
|
end
|
@@ -12,10 +12,10 @@ class Unidom::Position::PostReportingStructure < ActiveRecord::Base
|
|
12
12
|
scope :superior_post_is, ->(superior_post) { where superior_post_id: to_id(superior_post) }
|
13
13
|
scope :inferior_post_is, ->(inferior_post) { where inferior_post_id: to_id(inferior_post) }
|
14
14
|
|
15
|
-
def self.report!(superior_post: nil, inferior_post: nil, opened_at: Time.now
|
15
|
+
def self.report!(superior_post: nil, inferior_post: nil, elemental: true, opened_at: Time.now)
|
16
16
|
raise ArgumentError.new('The superior_post argument is required.') if superior_post.blank?
|
17
17
|
raise ArgumentError.new('The inferior_post argument is required.') if inferior_post.blank?
|
18
|
-
self.inferior_post_is(inferior_post).superior_post_is(superior_post).valid_at.alive.first_or_create!
|
18
|
+
self.inferior_post_is(inferior_post).superior_post_is(superior_post).valid_at.alive.first_or_create! elemental: elemental, opened_at: opened_at
|
19
19
|
end
|
20
20
|
|
21
21
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-position
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.2'
|
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-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.9'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.9'
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
@@ -40,6 +40,8 @@ files:
|
|
40
40
|
- app/assets/stylesheets/unidom/position/application.css
|
41
41
|
- app/controllers/unidom/position/application_controller.rb
|
42
42
|
- app/helpers/unidom/position/application_helper.rb
|
43
|
+
- app/models/unidom/position/concerns/as_inferior_post.rb
|
44
|
+
- app/models/unidom/position/concerns/as_superior_post.rb
|
43
45
|
- app/models/unidom/position/occupation.rb
|
44
46
|
- app/models/unidom/position/position.rb
|
45
47
|
- app/models/unidom/position/post.rb
|