unidom-product 0.3 → 0.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 +4 -4
- data/app/models/unidom/product/product_associating.rb +19 -0
- data/lib/unidom/product/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: e624865efbaf6ba17d3f4e149bfc4c0e7782d61f
|
|
4
|
+
data.tar.gz: 41ca96e289af3cc75d74cbd62b8897fa3b49f200
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f490de65ab811c55c5381274ddecb82ac1626aace2b618c96c6e18ccf9950c351f4d1d8dba93d25ed6def6515396baa16b848ea7da5a9b1c3ce64e80cced514b
|
|
7
|
+
data.tar.gz: e3be10c8e5db2b8029e1df961b6cd7dd3ff92bf8c547dec33061b5fa9aec1fbc432081a8289ac3ef84c0586d0cf763d635f0d928378dfadc6dc600bc89d4d6ee
|
|
@@ -19,4 +19,23 @@ class Unidom::Product::ProductAssociating < ActiveRecord::Base
|
|
|
19
19
|
belongs_to :source, class_name: 'Unidom::Product::Product'
|
|
20
20
|
belongs_to :target, class_name: 'Unidom::Product::Product'
|
|
21
21
|
|
|
22
|
+
scope :source_is, ->(product) { where source_id: to_id(product) }
|
|
23
|
+
scope :target_is, ->(product) { where target_id: to_id(product) }
|
|
24
|
+
|
|
25
|
+
def self.associate!(source, target, product_association_code, ordinal = 1, quantity = 1, opened_at = Time.now)
|
|
26
|
+
|
|
27
|
+
associating = source_is(source).target_is(target).product_association_coded_as(product_association_code).valid_at.alive.first
|
|
28
|
+
associating.soft_destroy if associating.present?
|
|
29
|
+
|
|
30
|
+
#if associating.present?
|
|
31
|
+
# associating.attributes = { ordinal: ordinal, quantity: quantity, opened_at: opened_at }
|
|
32
|
+
# associating.save!
|
|
33
|
+
#else
|
|
34
|
+
# associating = create! source_id: to_id(source), target_id: to_id(target), product_association_code: product_association_code, ordinal: ordinal, quantity: quantity, opened_at: opened_at
|
|
35
|
+
#end
|
|
36
|
+
#associating
|
|
37
|
+
create! source_id: to_id(source), target_id: to_id(target), product_association_code: product_association_code, ordinal: ordinal, quantity: quantity, opened_at: opened_at
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
22
41
|
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: '0.
|
|
4
|
+
version: '0.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-
|
|
11
|
+
date: 2016-08-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: unidom-common
|