unidom-product 1.7.7 → 1.7.8

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: 8d95506197821fb2b86634f9ea4767b1b66eb970
4
- data.tar.gz: 2582a40999d61d3699e43f22370e5b470d6c215f
3
+ metadata.gz: b967caae7491ed9756823e9db340f76f37697fc0
4
+ data.tar.gz: 237b58f54ca627f34fd702733838b15797d320b8
5
5
  SHA512:
6
- metadata.gz: 450b179167a954f7cf03345416b43b2135bb6052386254e6284544510813d2273cc54fd0c2b006e1f5301726eb8dd41404f8bd7f814bbf44f406d8d758adf145
7
- data.tar.gz: 95a98fb6e2cf23a8b35eb0b51d32fc75a26cac4c012326fc57693ae9722d7c0be3cdf33fd5da30f8ce3b9ae7d8ff7044b4b42188b890263c7995241a012c98b1
6
+ metadata.gz: 9a825adf7fef7ad823157e23b10e4b554e205eaf63f03d5a7401981e2a7d7e2ba56d777b6ea15e806d0bb8d5e6da5854ad37bea7e3aac17eae566a98c9a04fc2
7
+ data.tar.gz: ac4ccee09405d24f5a774f8a0ed6b24d493cd2803986db95ba65abba08f2e6d3299d7d477d24bd7663365a07e99e1b927c64421b285b70ec9c8a8281b46b9034
@@ -11,16 +11,6 @@ module Unidom::Product::Concerns::AsSourceProduct
11
11
  has_many :target_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :source_id
12
12
  has_many :target_products, through: :target_product_associatings, source: :target
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
-
20
- target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
21
-
22
- end
23
-
24
14
  def associate!(target, due_to: nil, at: Time.now, ordinal: 1)
25
15
 
26
16
  assert_present! :target, target
@@ -32,6 +22,16 @@ module Unidom::Product::Concerns::AsSourceProduct
32
22
 
33
23
  end
34
24
 
25
+ def associate?(target, due_to: nil, at: Time.now)
26
+
27
+ assert_present! :target, target
28
+ assert_present! :due_to, due_to
29
+ assert_present! :at, at
30
+
31
+ target_product_associatings.target_is(target).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
32
+
33
+ end
34
+
35
35
  end
36
36
 
37
37
  module ClassMethods
@@ -11,24 +11,24 @@ module Unidom::Product::Concerns::AsTargetProduct
11
11
  has_many :source_product_associatings, class_name: 'Unidom::Product::ProductAssociating', foreign_key: :target_id
12
12
  has_many :source_products, through: :source_product_associatings, source: :source
13
13
 
14
- def is_associated?(source, due_to: nil, at: Time.now)
14
+ def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
15
15
 
16
16
  assert_present! :source, source
17
17
  assert_present! :due_to, due_to
18
18
  assert_present! :at, at
19
+ assert_present! :ordinal, ordinal
19
20
 
20
- source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
21
+ 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
21
22
 
22
23
  end
23
24
 
24
- def is_associated!(source, due_to: nil, at: Time.now, ordinal: 1)
25
+ def is_associated?(source, due_to: nil, at: Time.now)
25
26
 
26
27
  assert_present! :source, source
27
28
  assert_present! :due_to, due_to
28
29
  assert_present! :at, at
29
- assert_present! :ordinal, ordinal
30
30
 
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
31
+ source_product_associatings.source_is(source).product_association_coded_as(due_to).valid_at(now: at).alive.exists?
32
32
 
33
33
  end
34
34
 
@@ -18,7 +18,7 @@ class Unidom::Product::ProductAssociating < Unidom::Product::ApplicationRecord
18
18
  include Unidom::Common::Concerns::ModelExtension
19
19
  include ProgneTapera::EnumCode
20
20
 
21
- validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1_000_000_000 }
21
+ validates :quantity, presence: true, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: Unidom::Common::MAXIMUM_AMOUNT }
22
22
 
23
23
  belongs_to :source, class_name: 'Unidom::Product::Product'
24
24
  belongs_to :target, class_name: 'Unidom::Product::Product'
@@ -16,8 +16,8 @@ class CreateUnidomProducts < ActiveRecord::Migration
16
16
 
17
17
  t.string :slug, null: false, default: nil, limit: 200
18
18
  t.column :state, 'char(1)', null: false, default: 'C'
19
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
20
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
19
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
20
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
21
21
  t.boolean :defunct, null: false, default: false
22
22
  t.jsonb :notation, null: false, default: {}
23
23
 
@@ -16,8 +16,8 @@ class CreateUnidomProductAssociatings < ActiveRecord::Migration
16
16
  t.text :instruction
17
17
 
18
18
  t.column :state, 'char(1)', null: false, default: 'C'
19
- t.datetime :opened_at, null: false, default: Time.utc(1970)
20
- t.datetime :closed_at, null: false, default: Time.utc(3000)
19
+ t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
20
+ t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
21
21
  t.boolean :defunct, null: false, default: false
22
22
  t.jsonb :notation, null: false, default: {}
23
23
 
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Product
3
- VERSION = '1.7.7'.freeze
3
+ VERSION = '1.7.8'.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.7
4
+ version: 1.7.8
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-14 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unidom-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '1.10'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '1.10'
27
27
  description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
28
28
  The Product domain model engine includes Product and its relative models. Unidom
29
29
  (统一领域对象模型)是一系列的领域模型引擎。产品领域模型引擎包括产品及其相关的模型。