unidom-product 1.2 → 1.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5974304bb2eb68ffab1a5c2813e8727dd65f79dc
|
4
|
+
data.tar.gz: 020bf02365fdcb42a0727c57a260b73e98cc5e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee61ade26e85062a2354482b678d7785119278452e8f04462a5fe008c4ae174b0dbe1dc1f3bc5ad80fafa30ed5a675666a9a2592e35ba79c121a9ecfcaff71e9
|
7
|
+
data.tar.gz: 79ac272f66669c7b17879fcd289cdeccc3ebd936472d4ba56eba46ec8dd4c1db4bd93567c0e44b6aedd04725ae038dfcce0fffcacb014b2350c9db7b2b4ce961
|
data/README.md
CHANGED
@@ -68,9 +68,11 @@ The As Source Product Associating concern do the following tasks for the include
|
|
68
68
|
1. Define the has_many :target_product_associatings macro as: ``has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id``
|
69
69
|
2. Define the has_many :target_products macro as: ``has_many :target_products, through: :target_product_associatings, source: :target``
|
70
70
|
3. Define the #associate! method as: ``associate!(target, due_to: nil, at: Time.now, ordinal: 1)``
|
71
|
+
4. Define the #associate? method as: ``associate?(target, due_to: nil, at: Time.now)``
|
71
72
|
|
72
73
|
### As Target Product Associating concern
|
73
74
|
The As Target Product Associating concern do the following tasks for the includer automatically:
|
74
75
|
1. Define the has_many :source_product_associatings macro as: ``has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id``
|
75
76
|
2. Define the has_many :source_products macro as: ``has_many :source_products, through: :source_product_associatings, source: :source``
|
76
77
|
3. Define the #is_associated! method as: ``is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)``
|
78
|
+
4. Define the #is_associated? method as: ``is_associated?(source, due_to: nil, at: Time.now)``
|
@@ -7,9 +7,9 @@ module Unidom::Product::Concerns::AsSourceProductAssociating
|
|
7
7
|
has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id
|
8
8
|
has_many :target_products, through: :target_product_associatings, source: :target
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def associate?(target, due_to: nil, at: Time.now)
|
11
|
+
target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
|
12
|
+
end
|
13
13
|
|
14
14
|
def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
|
15
15
|
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
|
@@ -7,9 +7,9 @@ module Unidom::Product::Concerns::AsTargetProductAssociating
|
|
7
7
|
has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id
|
8
8
|
has_many :source_products, through: :source_product_associatings, source: :source
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def is_associated?(source, due_to: nil, at: Time.now)
|
11
|
+
source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
|
12
|
+
end
|
13
13
|
|
14
14
|
def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
|
15
15
|
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
|
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.
|
4
|
+
version: '1.3'
|
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-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|