unidom-product 1.7.6 → 1.7.7

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: 2f993080afa9d9dc103a18ea6ff3c7525d3377a1
4
- data.tar.gz: c64047c0d8f6e667de20ecd3b03fc978dae8352f
3
+ metadata.gz: 8d95506197821fb2b86634f9ea4767b1b66eb970
4
+ data.tar.gz: 2582a40999d61d3699e43f22370e5b470d6c215f
5
5
  SHA512:
6
- metadata.gz: 581d43e50c2eb214df1ec045d689e29ede91ae4a1c6d7105bed01476a97e93d1849532a2b6fc92cb3ab892a99786adc55c9b521e335de37b40ae98ae96451d66
7
- data.tar.gz: b53789ef39c59f09939fdd1bda46bab7571239453238a11a930d10843a54bee16605c44f00f1293b4860ea6fe90d7dda3f6a39bccfd7fdc0c765680e6fb52ab9
6
+ metadata.gz: 450b179167a954f7cf03345416b43b2135bb6052386254e6284544510813d2273cc54fd0c2b006e1f5301726eb8dd41404f8bd7f814bbf44f406d8d758adf145
7
+ data.tar.gz: 95a98fb6e2cf23a8b35eb0b51d32fc75a26cac4c012326fc57693ae9722d7c0be3cdf33fd5da30f8ce3b9ae7d8ff7044b4b42188b890263c7995241a012c98b1
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Product::Concerns::AsSourceProduct
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -11,11 +12,24 @@ module Unidom::Product::Concerns::AsSourceProduct
11
12
  has_many :target_products, through: :target_product_associatings, source: :target
12
13
 
13
14
  def associate?(target, due_to: nil, at: Time.now)
15
+
16
+ assert_present! :target, target
17
+ assert_present! :due_to, due_to
18
+ assert_present! :at, at
19
+
14
20
  target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
21
+
15
22
  end
16
23
 
17
24
  def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
25
+
26
+ assert_present! :target, target
27
+ assert_present! :due_to, due_to
28
+ assert_present! :at, at
29
+ assert_present! :ordinal, ordinal
30
+
18
31
  target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.first_or_create! ordinal: ordinal, opened_at: at
32
+
19
33
  end
20
34
 
21
35
  end
@@ -3,7 +3,8 @@
3
3
 
4
4
  module Unidom::Product::Concerns::AsTargetProduct
5
5
 
6
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
7
+ include Unidom::Common::Concerns::ArgumentValidation
7
8
 
8
9
  included do |includer|
9
10
 
@@ -11,11 +12,24 @@ module Unidom::Product::Concerns::AsTargetProduct
11
12
  has_many :source_products, through: :source_product_associatings, source: :source
12
13
 
13
14
  def is_associated?(source, due_to: nil, at: Time.now)
15
+
16
+ assert_present! :source, source
17
+ assert_present! :due_to, due_to
18
+ assert_present! :at, at
19
+
14
20
  source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
21
+
15
22
  end
16
23
 
17
24
  def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
25
+
26
+ assert_present! :source, source
27
+ assert_present! :due_to, due_to
28
+ assert_present! :at, at
29
+ assert_present! :ordinal, ordinal
30
+
18
31
  source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.first_or_create! ordinal: ordinal, opened_at: at
32
+
19
33
  end
20
34
 
21
35
  end
@@ -18,6 +18,11 @@ shared_examples 'Unidom::Product::Concerns::AsSourceProduct' do |model_attribute
18
18
 
19
19
  it_behaves_like 'has_many', model_attributes, :target_product_associatings, Unidom::Product::ProductAssociating, [ target_product_associating_1_attribtues, target_product_associating_2_attribtues ]
20
20
 
21
+ model = described_class.create! model_attributes
22
+ target = described_class.create! model_attributes
23
+ it_behaves_like 'assert_present!', model, :associate!, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
24
+ it_behaves_like 'assert_present!', model, :associate?, [ target, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :target }, :due_to, :at ]
25
+
21
26
  end
22
27
 
23
28
  end
@@ -18,6 +18,11 @@ shared_examples 'Unidom::Product::Concerns::AsTargetProduct' do |model_attribute
18
18
 
19
19
  it_behaves_like 'has_many', model_attributes, :source_product_associatings, Unidom::Product::ProductAssociating, [ source_product_associating_1_attribtues, source_product_associating_2_attribtues ]
20
20
 
21
+ model = described_class.create! model_attributes
22
+ source = described_class.create! model_attributes
23
+ it_behaves_like 'assert_present!', model, :is_associated!, [ source, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :source }, :due_to, :at ]
24
+ it_behaves_like 'assert_present!', model, :is_associated?, [ source, { due_to: 'CPLM', at: Time.now } ], [ { 0 => :source }, :due_to, :at ]
25
+
21
26
  end
22
27
 
23
28
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Product
3
- VERSION = '1.7.6'.freeze
3
+ VERSION = '1.7.7'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unidom-product
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.6
4
+ version: 1.7.7
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-04-06 00:00:00.000000000 Z
11
+ date: 2017-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common