unidom-product 1.3 → 1.4

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: 5974304bb2eb68ffab1a5c2813e8727dd65f79dc
4
- data.tar.gz: 020bf02365fdcb42a0727c57a260b73e98cc5e9d
3
+ metadata.gz: 72045ffbc53a4fddb50505e43737898afa9d8c4b
4
+ data.tar.gz: 9ba22176c026d61d4836c0c0f89a1fe46d3ec052
5
5
  SHA512:
6
- metadata.gz: ee61ade26e85062a2354482b678d7785119278452e8f04462a5fe008c4ae174b0dbe1dc1f3bc5ad80fafa30ed5a675666a9a2592e35ba79c121a9ecfcaff71e9
7
- data.tar.gz: 79ac272f66669c7b17879fcd289cdeccc3ebd936472d4ba56eba46ec8dd4c1db4bd93567c0e44b6aedd04725ae038dfcce0fffcacb014b2350c9db7b2b4ce961
6
+ metadata.gz: e6b13c0ccd308e43041c1b1251b91f22deb835321f357de1a7d71ac7956cfe73ce8eab90a160ca08873d8df64fc61d8dfeb46cfb64a0583b2ce898633e94b08d
7
+ data.tar.gz: 7d1be11f8f4b362ebff50376af0366e4f1a6081d6b5f970ee858b75ed5ec2210ebd5be5aa598f02aa10f80b257bea594d1783a3ba4da3be89e87646459800630
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
4
4
  [![Gem Version](https://badge.fury.io/rb/unidom-product.svg)](https://badge.fury.io/rb/unidom-product)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-product.svg)](https://gemnasium.com/github.com/topbitdu/unidom-product)
5
6
 
6
7
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Product domain model engine includes Product and its relative models.
7
8
  Unidom (统一领域对象模型)是一系列的领域模型引擎。产品领域模型引擎包括产品及其相关的模型。
@@ -59,20 +60,22 @@ associating = Unidom::Product::ProductAssociating.source_is(product_1).target_is
59
60
  ## Include the Concerns
60
61
 
61
62
  ```ruby
62
- include Unidom::Product::Concerns::AsSourceProductAssociating
63
- include Unidom::Product::Concerns::AsTargetProductAssociating
63
+ include Unidom::Product::Concerns::AsSourceProduct
64
+ include Unidom::Product::Concerns::AsTargetProduct
64
65
  ```
65
66
 
66
- ### As Source Product Associating concern
67
- The As Source Product Associating concern do the following tasks for the includer automatically:
67
+ ### As Source Product concern
68
+
69
+ The As Source Product concern do the following tasks for the includer automatically:
68
70
  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
- 2. Define the has_many :target_products macro as: ``has_many :target_products, through: :target_product_associatings, source: :target``
70
- 3. Define the #associate! method as: ``associate!(target, due_to: nil, at: Time.now, ordinal: 1)``
71
+ 2. Define the has_many :target_products macro as: ``has_many :target_products, through: :target_product_associatings, source: :target``
72
+ 3. Define the #associate! method as: ``associate!(target, due_to: nil, at: Time.now, ordinal: 1)``
71
73
  4. Define the #associate? method as: ``associate?(target, due_to: nil, at: Time.now)``
72
74
 
73
- ### As Target Product Associating concern
74
- The As Target Product Associating concern do the following tasks for the includer automatically:
75
+ ### As Target Product concern
76
+
77
+ The As Target Product concern do the following tasks for the includer automatically:
75
78
  1. Define the has_many :source_product_associatings macro as: ``has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id``
76
- 2. Define the has_many :source_products macro as: ``has_many :source_products, through: :source_product_associatings, source: :source``
77
- 3. Define the #is_associated! method as: ``is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)``
79
+ 2. Define the has_many :source_products macro as: ``has_many :source_products, through: :source_product_associatings, source: :source``
80
+ 3. Define the #is_associated! method as: ``is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)``
78
81
  4. Define the #is_associated? method as: ``is_associated?(source, due_to: nil, at: Time.now)``
@@ -0,0 +1,23 @@
1
+ module Unidom::Product::Concerns::AsSourceProduct
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id
8
+ has_many :target_products, through: :target_product_associatings, source: :target
9
+
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
+
14
+ def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
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
16
+ end
17
+
18
+ end
19
+
20
+ module ClassMethods
21
+ end
22
+
23
+ end
@@ -8,10 +8,12 @@ module Unidom::Product::Concerns::AsSourceProductAssociating
8
8
  has_many :target_products, through: :target_product_associatings, source: :target
9
9
 
10
10
  def associate?(target, due_to: nil, at: Time.now)
11
+ warn "The Unidom::Product::Concerns::AsSourceProductAssociating#associate? method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsSourceProduct#associate? method instead."
11
12
  target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
12
13
  end
13
14
 
14
15
  def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
16
+ warn "The Unidom::Product::Concerns::AsSourceProductAssociating#associate! method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsSourceProduct#associate! method instead."
15
17
  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
16
18
  end
17
19
 
@@ -0,0 +1,23 @@
1
+ module Unidom::Product::Concerns::AsTargetProduct
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ included do |includer|
6
+
7
+ has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id
8
+ has_many :source_products, through: :source_product_associatings, source: :source
9
+
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
+
14
+ def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
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
16
+ end
17
+
18
+ end
19
+
20
+ module ClassMethods
21
+ end
22
+
23
+ end
@@ -8,10 +8,12 @@ module Unidom::Product::Concerns::AsTargetProductAssociating
8
8
  has_many :source_products, through: :source_product_associatings, source: :source
9
9
 
10
10
  def is_associated?(source, due_to: nil, at: Time.now)
11
+ warn "The Unidom::Product::Concerns::AsTargetProductAssociating#is_associated? method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsTargetProduct#is_associated? method instead."
11
12
  source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
12
13
  end
13
14
 
14
15
  def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
16
+ warn "The Unidom::Product::Concerns::AsTargetProductAssociating#is_associated! method is deprecated and will be removed from unidom-product v2.0. Please use the Unidom::Product::Concerns::AsTargetProduct#is_associated! method instead."
15
17
  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
16
18
  end
17
19
 
@@ -5,8 +5,8 @@ class Unidom::Product::Product < ActiveRecord::Base
5
5
  self.table_name = 'unidom_products'
6
6
 
7
7
  include Unidom::Common::Concerns::ModelExtension
8
- include Unidom::Product::Concerns::AsSourceProductAssociating
9
- include Unidom::Product::Concerns::AsTargetProductAssociating
8
+ include Unidom::Product::Concerns::AsSourceProduct
9
+ include Unidom::Product::Concerns::AsTargetProduct
10
10
 
11
11
  validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
12
12
  validates :abbreviation, presence: true, length: { in: 1..self.columns_hash['abbreviation'].limit }
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Product
3
- VERSION = '1.3'.freeze
3
+ VERSION = '1.4'.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.3'
4
+ version: '1.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-10-02 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -40,7 +40,9 @@ files:
40
40
  - app/assets/stylesheets/unidom/product/application.css
41
41
  - app/controllers/unidom/product/application_controller.rb
42
42
  - app/helpers/unidom/product/application_helper.rb
43
+ - app/models/unidom/product/concerns/as_source_product.rb
43
44
  - app/models/unidom/product/concerns/as_source_product_associating.rb
45
+ - app/models/unidom/product/concerns/as_target_product.rb
44
46
  - app/models/unidom/product/concerns/as_target_product_associating.rb
45
47
  - app/models/unidom/product/product.rb
46
48
  - app/models/unidom/product/product_associating.rb