unidom-position 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56b90af2bb4f6f1323b250f73a3ae94809836dec
4
- data.tar.gz: 45a77a41d29fd24921126dc93583064574922b82
3
+ metadata.gz: 80e180955365b86c13d846f158c09e0b0d4e8481
4
+ data.tar.gz: 925df0f09a34d753c08477b0038ec496c30f569c
5
5
  SHA512:
6
- metadata.gz: 420a76be6bb9a848ab84ae646cab39b959cc9e82657b90cf760b77c5e5adf355f8917ad73eaa8bfc5e33964e1d7aedfa11eec4c845dd5844d05d8741c6761a2d
7
- data.tar.gz: 85ad988a4a1673ee2fc12f41b743712dabd7f2455424767e2644d1fef44fac11a01044f4cd539f21446c43c54a07c2608dac5c2130cb99d7ea084986561d2fe6
6
+ metadata.gz: de79f6dc7e5fcf1bb85e1c3b4d66943721d266551fa447d13d6ae9f3822e12252d190caf4e34fb9987cd5ba3b635b140f53e23084ca69b5ef0c153aeb9df10c7
7
+ data.tar.gz: e44f83de2faa6d66b64d930b00c6120ac8731a36bfd1ed31f74bffca81da1df4b7d5cc772c9e4f722974e4ff3a3876594cec39d86aa3ecba13eb0a3ba1ffcf31
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Unidom Position 职位领域模型引擎
2
2
 
3
+ [![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/unidom-position/frames)
3
4
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
5
+
4
6
  [![Gem Version](https://badge.fury.io/rb/unidom-position.svg)](https://badge.fury.io/rb/unidom-position)
5
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-position.svg)](https://gemnasium.com/github.com/topbitdu/unidom-position)
6
8
 
@@ -69,16 +71,40 @@ include Unidom::Position::Concerns::AsSuperiorPost
69
71
 
70
72
  ### As Inferior Post
71
73
 
72
- The As Inferior Post concern do the following tasks for the includer automatically:
73
- 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``
74
- 2. Define the has_many :superior_posts macro as: ``has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post``
75
- 3. Define the #report_to! method as: ``report_to!(superior_post, at: Time.now, primary: true)``
74
+ The As Inferior Post concern do the following tasks for the includer automatically:
75
+
76
+ 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``
77
+
78
+ 2. Define the has_many :superior_posts macro as: ``has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post``
79
+
80
+ 3. Define the #report_to! method as: ``report_to!(superior_post, at: Time.now, primary: true)``
81
+
76
82
  4. Define the #report_to? method as: ``report_to?(superior_post, at: Time.now, primary: true)``
77
83
 
78
84
  ### As Superior Post
79
85
 
80
- The As Superior Post concern do the following tasks for the includer automatically:
81
- 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``
82
- 2. Define the has_many :inferior_posts macro as: ``has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post``
83
- 3. Define the #is_reported_to! method as: ``is_reported_to!(by: nil, at: Time.now, primary: true)``
86
+ The As Superior Post concern do the following tasks for the includer automatically:
87
+
88
+ 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``
89
+
90
+ 2. Define the has_many :inferior_posts macro as: ``has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post``
91
+
92
+ 3. Define the #is_reported_to! method as: ``is_reported_to!(by: nil, at: Time.now, primary: true)``
93
+
84
94
  4. Define the #is_reported_to? method as: ``is_reported_to?(by: nil, at: Time.now, primary: true)``
95
+
96
+
97
+
98
+ ## Disable the Model & Migration
99
+
100
+ If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
101
+ ```ruby
102
+ # config/initializers/unidom.rb
103
+ Unidom::Common.configure do |options|
104
+
105
+ options[:neglected_namespaces] = %w{
106
+ Unidom::Position
107
+ }
108
+
109
+ end
110
+ ```
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application controller 是模块内所有控制器的基类。
3
+
1
4
  class Unidom::Position::ApplicationController < ActionController::Base
2
5
  protect_from_forgery with: :exception
3
6
  end
@@ -1,2 +1,5 @@
1
+ ##
2
+ # Application job 是模块内所有异步任务的基类。
3
+
1
4
  class Unidom::Position::ApplicationJob < ActiveJob::Base
2
5
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application mailer 是模块内所有电子邮件发送类的基类。
3
+
1
4
  class Unidom::Position::ApplicationMailer < ActionMailer::Base
2
5
  default from: 'from@example.com'
3
6
  layout 'mailer'
@@ -1,3 +1,6 @@
1
+ ##
2
+ # Application record 是模块内所有模型的抽象基类。
3
+
1
4
  class Unidom::Position::ApplicationRecord < ActiveRecord::Base
2
5
  self.abstract_class = true
3
6
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # As Inferior Post 是下级岗位的领域逻辑关注点。
3
+
1
4
  module Unidom::Position::Concerns::AsInferiorPost
2
5
 
3
6
  extend ActiveSupport::Concern
@@ -7,6 +10,10 @@ module Unidom::Position::Concerns::AsInferiorPost
7
10
  has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :inferior_post, foreign_key: :inferior_post_id
8
11
  has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post
9
12
 
13
+ ##
14
+ # 以下级岗位的身份与上级岗位 superior_post 建立岗位间的上下级汇报关系。
15
+ # 主要汇报标志是 primary ,缺省为 true 。建立时间是 at ,缺省为当前时间。如:
16
+ # rails_developer.report_to! project_manager, primary: false
10
17
  def report_to!(superior_post, at: Time.now, primary: true)
11
18
  superior_post_reporting_structures.superior_post_is(superior_post).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
19
  end
@@ -1,3 +1,6 @@
1
+ ##
2
+ # As Superior Post 是上级岗位的领域逻辑关注点。
3
+
1
4
  module Unidom::Position::Concerns::AsSuperiorPost
2
5
 
3
6
  extend ActiveSupport::Concern
@@ -7,6 +10,10 @@ module Unidom::Position::Concerns::AsSuperiorPost
7
10
  has_many :inferior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :superior_post, foreign_key: :superior_post_id
8
11
  has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post
9
12
 
13
+ ##
14
+ # 以上级岗位的身份与下级岗位 by 建立岗位间的上下级汇报关系。
15
+ # 主要汇报标志是 primary ,缺省为 true 。建立时间是 at ,缺省为当前时间。如:
16
+ # project_manager.is_reported_to! by: rails_developer, primary: false
10
17
  def is_reported_to!(by: nil, at: Time.now, primary: true)
11
18
  inferior_post_reporting_structures.inferior_post_is(by).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
19
  end
@@ -18,4 +18,4 @@ class Unidom::Position::Occupation < Unidom::Position::ApplicationRecord
18
18
  scope :scheme_id_is, ->(scheme_id) { where scheme_id: scheme_id }
19
19
  scope :scheme_type_is, ->(scheme_type) { where scheme_type: scheme_type }
20
20
 
21
- end
21
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Position::Occupation'
@@ -14,4 +14,4 @@ class Unidom::Position::Position < Unidom::Position::ApplicationRecord
14
14
 
15
15
  has_many :posts, class_name: 'Unidom::Position::Post'
16
16
 
17
- end
17
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Position::Position'
@@ -14,4 +14,4 @@ class Unidom::Position::Post < Unidom::Position::ApplicationRecord
14
14
  belongs_to :organization, polymorphic: true
15
15
  belongs_to :position, class_name: 'Unidom::Position::Position'
16
16
 
17
- end
17
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Position::Post'
@@ -13,10 +13,14 @@ class Unidom::Position::PostReportingStructure < Unidom::Position::ApplicationRe
13
13
  scope :superior_post_is, ->(superior_post) { where superior_post_id: to_id(superior_post) }
14
14
  scope :inferior_post_is, ->(inferior_post) { where inferior_post_id: to_id(inferior_post) }
15
15
 
16
+ ##
17
+ # 建立岗位间的上下级汇报关系。上级岗位是 superior_post ,下级岗位是 inferior_post 。
18
+ # 主要汇报标志是 elemental ,缺省为 true 。建立时间是 opened_at ,缺省为当前时间。如:
19
+ # Unidom::Position::PostReportingStructure.report! superior_post: superior_post, inferior_post: inferior_post
16
20
  def self.report!(superior_post: nil, inferior_post: nil, elemental: true, opened_at: Time.now)
17
21
  raise ArgumentError.new('The superior_post argument is required.') if superior_post.blank?
18
22
  raise ArgumentError.new('The inferior_post argument is required.') if inferior_post.blank?
19
23
  self.inferior_post_is(inferior_post).superior_post_is(superior_post).valid_at.alive.first_or_create! elemental: elemental, opened_at: opened_at
20
24
  end
21
25
 
22
- end
26
+ end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Position::PostReportingStructure'
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Position
3
- VERSION = '1.4.4'.freeze
3
+ VERSION = '1.4.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-position
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Topbit Du
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '1.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
- version: '1.8'
26
+ version: '1.9'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Position domain model engine includes the Occupation, Position, Post, and Position
29
29
  Reporting Structure models. Unidom (统一领域对象模型)是一系列的领域模型引擎。职位领域模型引擎包括职业、职位、岗位及职位报告关系模型。