unidom-position 0.2 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/app/models/unidom/position/post_reporting_structure.rb +3 -1
- data/lib/unidom/position/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1645f47e2078c818ae2521a0fa4e2621ddcc112a
|
4
|
+
data.tar.gz: e3300b3cf9f605a7c9844157142fce0a2555a638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f67b7a15021ba82e057f6c8c5a0dbff3eb4f29d05ae8f40ddf8ddc22d1f29b04eabdde53ab2fa0e04d1403d2a8d42f2e4eb244bd65e65448df46a5a51d40c80
|
7
|
+
data.tar.gz: 14c43856faaeaf8b44c66dd484711eaec3a260212bf9ab634401d3cb5f3061bcf26d665fd80ed880c429e044b65256eee6cd63b24cf9b079bb13201b6fbf5cef
|
data/README.md
CHANGED
@@ -23,12 +23,16 @@ The migration versions start with 200101.
|
|
23
23
|
|
24
24
|
## Call the Model
|
25
25
|
```ruby
|
26
|
-
position = Unidom::Position::Position.valid_at.alive.first
|
27
26
|
|
28
27
|
occupation = Unidom::Position::Occupation.valid_at.alive.first
|
29
28
|
|
29
|
+
position = Unidom::Position::Position.valid_at.alive.first
|
30
|
+
|
30
31
|
post = Unidom::Position::Post.valid_at.alive.first
|
31
32
|
|
32
|
-
Unidom::Position::
|
33
|
+
chief_programmer = Unidom::Position::Post.create! name: 'Chief Programmer', position: position
|
34
|
+
erlang_developer = Unidom::Position::Post.create! name: 'Erlang Developer', position: position
|
35
|
+
|
36
|
+
Unidom::Position::PostReportingStructure.report!(superior_post: chief_programmer, inferior_post: erlang_developer, opened_at: Time.now, elemental: true)
|
33
37
|
|
34
38
|
```
|
@@ -12,7 +12,9 @@ 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, inferior_post, opened_at
|
15
|
+
def self.report!(superior_post: nil, inferior_post: nil, opened_at: Time.now, elemental: true)
|
16
|
+
raise ArgumentError.new('The superior_post argument is required.') if superior_post.blank?
|
17
|
+
raise ArgumentError.new('The inferior_post argument is required.') if inferior_post.blank?
|
16
18
|
self.inferior_post_is(inferior_post).superior_post_is(superior_post).valid_at.alive.first_or_create! opened_at: opened_at, elemental: elemental
|
17
19
|
end
|
18
20
|
|
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: '0
|
4
|
+
version: '1.0'
|
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-06-
|
11
|
+
date: 2016-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|