unidom-standard 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01720c46356631eb0988ead8a6c9ac0b3c5b6cdc
4
- data.tar.gz: d61712c2fb0d996d24136040930c20e4877db93f
3
+ metadata.gz: 0d089cfe024b797df5ef3c97e9ef80727a2e580d
4
+ data.tar.gz: 90c396b43e2b4508a84009cfd1319b48145b69de
5
5
  SHA512:
6
- metadata.gz: 057cca46172492ee3ecb7ffa4003036bef2c4a101b3709f71d2b779d7534e990fb564756b165c3adcac72eca0582963cd203a0a64ec635890250fadd3462544b
7
- data.tar.gz: 3d4fd6057b406e90bc410bcc7fb98778f8231543fc8e1276838ecb211e2c4a5bf32eed07a3414a523ef4d9336c04f1ef82a36bf406114b13b0e9a48d5cc6b41a
6
+ metadata.gz: 7a5b0c57bd3da3b3f3d4208f1964f05eae536e93c4598a318c76bede4a2c86aa3030aa6f395955979f2d4e341854548337fefe7274715c88433abc2a148b2805
7
+ data.tar.gz: 6f426bdebc2e020ed49417d7dde35bc1069bd22d21cf3208392163c970be8292940917bef707256cf850309b6ad9ce6068eea06c018f02e9e58fa7c5424b1811
data/README.md CHANGED
@@ -45,8 +45,10 @@ include Unidom::Standard::Concerns::AsTargetStandard
45
45
  The As Source Standard concern do the following tasks for the includer automatically:
46
46
  1. Define the has_many :target_associatings macro as: ``has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id``
47
47
  2. Define the has_many :target_standards macro as: ``has_many :target_standards, through: :target_associatings, source: :target``
48
+ 3. Define the #associate! method as: ``associate!(target, due_to: 'REVS', at: Time.now)``
48
49
 
49
50
  ### As Target Standard concern
50
51
  The As Target Standard concern do the following tasks for the includer automatically:
51
52
  1. Define the has_many :source_associatings macro as: ``has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id``
52
53
  2. Define the has_many :source_standards macro as: ``has_many :source_standards, through: :source_associatings, source: :source``
54
+ 3. Define the #is_associated! method as: ``is_associated!(source, due_to: 'REVS', at: Time.now)``
@@ -7,6 +7,14 @@ module Unidom::Standard::Concerns::AsSourceStandard
7
7
  has_many :target_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :source_id
8
8
  has_many :target_standards, through: :target_associatings, source: :target
9
9
 
10
+ def associate!(target, due_to: 'REVS', at: Time.now)
11
+ target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at
12
+ end
13
+
14
+ #def associate?(target, due_to: 'REVS', at: Time.now)
15
+ # target_associatings.target_is(target).association_coded_as(due_to).valid_at(now: at).alive.exists?
16
+ #end
17
+
10
18
  end
11
19
 
12
20
  module ClassMethods
@@ -7,6 +7,14 @@ module Unidom::Standard::Concerns::AsTargetStandard
7
7
  has_many :source_associatings, class_name: 'Unidom::Standard::StandardAssociating', foreign_key: :target_id
8
8
  has_many :source_standards, through: :source_associatings, source: :source
9
9
 
10
+ def is_associated!(source, due_to: 'REVS', at: Time.now)
11
+ source_associatings.source_is(source).association_coded_as(due_to).valid_at(now: at).alive.first_or_create! opened_at: at
12
+ end
13
+
14
+ #def is_associated?(source, due_to: 'REVS', at: Time.now)
15
+ # source_associatings.source_is(source).association_coded_as(due_to).valid_at(now: at).alive.exists?
16
+ #end
17
+
10
18
  end
11
19
 
12
20
  module ClassMethods
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Standard
3
- VERSION = '1.1'.freeze
3
+ VERSION = '1.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-standard
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.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-08-30 00:00:00.000000000 Z
11
+ date: 2016-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common