unidom-position 1.3 → 1.4

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: 08bcb9be7f29b4850fca33fd2de11bc69a14d6eb
4
- data.tar.gz: 5550bb98686bbb08082eefe201da839d64caee6e
3
+ metadata.gz: a325387226fa0999af27eaae18507795913ea095
4
+ data.tar.gz: a3b4c43bc38dbf72d60b6107145587c8721f445a
5
5
  SHA512:
6
- metadata.gz: b1b6f6bbf032fce2aa4339bdf06c85e77a354618f4348747e7563bbfcfd436299118a9912ddb28e6839e7940bd26129e7c51420a6bce40a74e96f29a4fbe5710
7
- data.tar.gz: dbd097337fb6a25218b2c920dd5643b6a47ee39ab1bdcdbf378734945cbc62d7c45817cf59f7aa7cae117a4702605254b7113dc36391f1e2a48a7fb9619447e8
6
+ metadata.gz: 9d8c58a8bb124046ef4230e7ece3bebf815b70a77866d9461fb540a4f7d30720a2076837a6eba5abf0801a66cba00ae419928558032262f0aba6298310d2bd76
7
+ data.tar.gz: 94a34fb04dfc9b320e36a08d2535d020ad9da9c34e698c7d62d2614fff4a0b0888ee2500967f77522a1082f2933a7b3920f52c4b8b6f06cc7a96e147b2f8451a
data/README.md CHANGED
@@ -53,10 +53,12 @@ include Unidom::Position::Concerns::AsSuperiorPost
53
53
  The As Inferior Post concern do the following tasks for the includer automatically:
54
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
55
  2. Define the has_many :superior_posts macro as: ``has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post``
56
- 3. Define the #report_to! method as: ``def report_to!(superior_post, at: Time.now, primary: false)``
56
+ 3. Define the #report_to! method as: ``report_to!(superior_post, at: Time.now, primary: true)``
57
+ 4. Define the #report_to? method as: ``report_to?(superior_post, at: Time.now, primary: true)``
57
58
 
58
59
  ### As Superior Post
59
60
  The As Superior Post concern do the following tasks for the includer automatically:
60
61
  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``
61
62
  2. Define the has_many :inferior_posts macro as: ``has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post``
62
- 3. Define the #is_reported_to! method as: ``def is_reported_to!(by: nil, at: Time.now, primary: false)``
63
+ 3. Define the #is_reported_to! method as: ``is_reported_to!(by: nil, at: Time.now, primary: true)``
64
+ 4. Define the #is_reported_to? method as: ``is_reported_to?(by: nil, at: Time.now, primary: true)``
@@ -7,8 +7,12 @@ module Unidom::Position::Concerns::AsInferiorPost
7
7
  has_many :superior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :inferior_post, foreign_key: :inferior_post_id
8
8
  has_many :superior_posts, through: :superior_post_reporting_structures, source: :superior_post
9
9
 
10
- def report_to!(superior_post, at: Time.now, primary: false)
11
- superior_post_reporting_structures.create! superior_post: superior_post, elemental: primary, opened_at: at
10
+ def report_to!(superior_post, at: Time.now, primary: true)
11
+ superior_post_reporting_structures.superior_post_is(superior_post).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
+ end
13
+
14
+ def report_to?(superior_post, at: Time.now, primary: true)
15
+ superior_post_reporting_structures.superior_post_is(superior_post).valid_at(now: at).alive.primary(primary).exists?
12
16
  end
13
17
 
14
18
  end
@@ -7,8 +7,12 @@ module Unidom::Position::Concerns::AsSuperiorPost
7
7
  has_many :inferior_post_reporting_structures, class_name: 'Unidom::Position::PostReportingStructure', source: :superior_post, foreign_key: :superior_post_id
8
8
  has_many :inferior_posts, through: :inferior_post_reporting_structures, source: :inferior_post
9
9
 
10
- def is_reported_to!(by: nil, at: Time.now, primary: false)
11
- inferior_post_reporting_structures.create! inferior_post: by, elemental: primary, opened_at: at
10
+ def is_reported_to!(by: nil, at: Time.now, primary: true)
11
+ inferior_post_reporting_structures.inferior_post_is(by).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
+ end
13
+
14
+ def is_reported_to?(by: nil, at: Time.now, primary: true)
15
+ inferior_post_reporting_structures.inferior_post_is(by).valid_at(now: at).alive.primary(primary).exists?
12
16
  end
13
17
 
14
18
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Position
3
- VERSION = '1.3'.freeze
3
+ VERSION = '1.4'.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.3'
4
+ version: '1.4'
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-30 00:00:00.000000000 Z
11
+ date: 2016-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common