unidom-product 0.4 → 1.0

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: e624865efbaf6ba17d3f4e149bfc4c0e7782d61f
4
- data.tar.gz: 41ca96e289af3cc75d74cbd62b8897fa3b49f200
3
+ metadata.gz: eec6cc009a7832a8b54efc5d072b77c5ccce2ad0
4
+ data.tar.gz: 435f58b1832e69ae946fce6a82e0d2e067c54932
5
5
  SHA512:
6
- metadata.gz: f490de65ab811c55c5381274ddecb82ac1626aace2b618c96c6e18ccf9950c351f4d1d8dba93d25ed6def6515396baa16b848ea7da5a9b1c3ce64e80cced514b
7
- data.tar.gz: e3be10c8e5db2b8029e1df961b6cd7dd3ff92bf8c547dec33061b5fa9aec1fbc432081a8289ac3ef84c0586d0cf763d635f0d928378dfadc6dc600bc89d4d6ee
6
+ metadata.gz: efed501763cd32d445c46d7fca604340373a3675a2a10937f6d6247dbd31787b53a3758a1f6bc5db45281cedeac05e4181a9f157c0e88217aa4f9fb0b61175a0
7
+ data.tar.gz: 91d1ffda19db36b028a54778996bf44b5a776886508311c02997fb5665ac78988b84f8ecd1e69848685efd9935de158ad25a533b0a30de84a684c1254f16a675
data/README.md CHANGED
@@ -34,4 +34,10 @@ product = Unidom::Product::Product.create(name: 'Apple iPhone 6S Plus 64G',
34
34
 
35
35
  # Find the Product per Formset Code
36
36
  Product.formset_coded_as('SRVC').valid_at.alive.first
37
+
38
+ # Associate 2 products as incompatible
39
+ Unidom::Product::ProductAssociating.associate! product_1, with: product_2, due_to: 'ICPT', ordinal: 1, quantity: 1, at: Time.now
40
+
41
+ # Find the Product Associating per the source product & the target product
42
+ associating = Unidom::Product::ProductAssociating.source_is(product_1).target_is(product_2).first
37
43
  ```
@@ -22,9 +22,9 @@ class Unidom::Product::ProductAssociating < ActiveRecord::Base
22
22
  scope :source_is, ->(product) { where source_id: to_id(product) }
23
23
  scope :target_is, ->(product) { where target_id: to_id(product) }
24
24
 
25
- def self.associate!(source, target, product_association_code, ordinal = 1, quantity = 1, opened_at = Time.now)
25
+ def self.associate!(source, with: target, due_to: 'PCKG', ordinal: 1, quantity: 1, at: Time.now)
26
26
 
27
- associating = source_is(source).target_is(target).product_association_coded_as(product_association_code).valid_at.alive.first
27
+ associating = source_is(source).target_is(with).product_association_coded_as(due_to).valid_at.alive.first
28
28
  associating.soft_destroy if associating.present?
29
29
 
30
30
  #if associating.present?
@@ -34,7 +34,7 @@ class Unidom::Product::ProductAssociating < ActiveRecord::Base
34
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
35
  #end
36
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
37
+ create! source_id: to_id(source), target_id: to_id(with), product_association_code: due_to, ordinal: ordinal, quantity: quantity, opened_at: at
38
38
 
39
39
  end
40
40
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Product
3
- VERSION = '0.4'.freeze
3
+ VERSION = '1.0'.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: '0.4'
4
+ version: '1.0'
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-25 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common