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 +4 -4
- data/app/models/unidom/product/concerns/as_source_product.rb +10 -10
- data/app/models/unidom/product/concerns/as_target_product.rb +5 -5
- data/app/models/unidom/product/product_associating.rb +1 -1
- data/db/migrate/20020201000000_create_unidom_products.rb +2 -2
- data/db/migrate/20020211000000_create_unidom_product_associatings.rb +2 -2
- data/lib/unidom/product/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b967caae7491ed9756823e9db340f76f37697fc0
|
4
|
+
data.tar.gz: 237b58f54ca627f34fd702733838b15797d320b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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
|
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.
|
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:
|
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: ::
|
20
|
-
t.datetime :closed_at, null: false, default: ::
|
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:
|
20
|
-
t.datetime :closed_at, null: false, default:
|
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
|
|
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.
|
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-
|
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.
|
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.
|
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
|
(统一领域对象模型)是一系列的领域模型引擎。产品领域模型引擎包括产品及其相关的模型。
|