unidom-category 1.5.4 → 1.5.5
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/README.md +33 -15
- data/app/controllers/unidom/category/application_controller.rb +3 -0
- data/app/jobs/unidom/category/application_job.rb +3 -0
- data/app/mailers/unidom/category/application_mailer.rb +3 -0
- data/app/models/unidom/category/application_record.rb +3 -0
- data/app/models/unidom/category/categorizing.rb +1 -5
- data/app/models/unidom/category/category.rb +1 -1
- data/app/models/unidom/category/category_rollup.rb +4 -1
- data/app/models/unidom/category/category_scheme.rb +1 -1
- data/lib/unidom/category/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: 3cf9e49d71c90a9c481326d894c7732dd9d11448
|
|
4
|
+
data.tar.gz: 90fa319d17a4d5f8c2839195efe789004a16aa41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e1523a1109f18d34975673eb6b0389e01a22d5070c835193d3ef48efdd630648511a3b4d378cd66efe1673d16af83b7456eb9f93ed9dae2e7d8a34bfc8e5dcd
|
|
7
|
+
data.tar.gz: 29701235a9a5351867cfe96b8f19176286169f72c475b82e028b809d54455233bc45ee034d98b9ebabd3cdc1835d9600a6198afd03ac4b9ae8f7e0604b1df717
|
data/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# Unidom Category 类别领域模型引擎
|
|
2
2
|
|
|
3
|
+
[](http://www.rubydoc.info/gems/unidom-category/frames)
|
|
3
4
|
[](http://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
4
6
|
[](https://badge.fury.io/rb/unidom-category)
|
|
5
7
|
[](https://gemnasium.com/github.com/topbitdu/unidom-category)
|
|
6
8
|
|
|
@@ -58,31 +60,47 @@ include Unidom::Category::Concerns::AsDescendantCategory
|
|
|
58
60
|
|
|
59
61
|
### As Category concern
|
|
60
62
|
|
|
61
|
-
The As Category concern do the following tasks for the includer automatically:
|
|
62
|
-
1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Category::Categorizing'``
|
|
63
|
-
2. Define the #categorize! method as: ``categorize!(categorized, at: Time.now, primary: true)``
|
|
63
|
+
The As Category concern do the following tasks for the includer automatically:
|
|
64
|
+
1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Category::Categorizing'``
|
|
65
|
+
2. Define the #categorize! method as: ``categorize!(categorized, at: Time.now, primary: true)``
|
|
64
66
|
3. Define the #categorize? method as: ``categorize?(categorized, at: Time.now, primary: true)``
|
|
65
67
|
|
|
66
68
|
### As Categorized concern
|
|
67
69
|
|
|
68
|
-
The As Categorized concern do the following tasks for the includer automatically:
|
|
69
|
-
1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized``
|
|
70
|
-
2. Define the has_many :categories macro as: ``has_many :categories, through: :categorizings, source: :category``
|
|
71
|
-
3. Define the #is_categorized! method as: ``is_categorized!(into: nil, at: Time.now, primary: true)``
|
|
70
|
+
The As Categorized concern do the following tasks for the includer automatically:
|
|
71
|
+
1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized``
|
|
72
|
+
2. Define the has_many :categories macro as: ``has_many :categories, through: :categorizings, source: :category``
|
|
73
|
+
3. Define the #is_categorized! method as: ``is_categorized!(into: nil, at: Time.now, primary: true)``
|
|
72
74
|
4. Define the #is_categorized? method as: ``is_categorized?(into: nil, at: Time.now, primary: true)``
|
|
73
75
|
|
|
74
76
|
### As Ancestor Category concern
|
|
75
77
|
|
|
76
|
-
The As Ancestor Category concern do the following tasks for the includer automatically:
|
|
77
|
-
1. Define the has_many :descendant_category_rollups macro as: ``has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category``
|
|
78
|
-
2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
|
|
79
|
-
3. Define the #roll_up! method as: ``roll_up!(it, at: Time.now, primary: true)``
|
|
78
|
+
The As Ancestor Category concern do the following tasks for the includer automatically:
|
|
79
|
+
1. Define the has_many :descendant_category_rollups macro as: ``has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category``
|
|
80
|
+
2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
|
|
81
|
+
3. Define the #roll_up! method as: ``roll_up!(it, at: Time.now, primary: true)``
|
|
80
82
|
4. Define the #roll_up? method as: ``roll_up?(it, at: Time.now, primary: true)``
|
|
81
83
|
|
|
82
84
|
### As Descendant Category concern
|
|
83
85
|
|
|
84
|
-
The As Descendant Category concern do the following tasks for the includer automatically:
|
|
85
|
-
1. Define the has_many :ancestor_category_rollups macro as: ``has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category``
|
|
86
|
-
2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
|
|
87
|
-
3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
|
|
86
|
+
The As Descendant Category concern do the following tasks for the includer automatically:
|
|
87
|
+
1. Define the has_many :ancestor_category_rollups macro as: ``has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category``
|
|
88
|
+
2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
|
|
89
|
+
3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
|
|
88
90
|
4. Define the #is_rolled_up? as: ``is_rolled_up?(it, at: Time.now, primary: true)``
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Disable the Model & Migration
|
|
95
|
+
|
|
96
|
+
If you only need the app components other than models, the migrations should be neglected, and the models should not be loaded.
|
|
97
|
+
```ruby
|
|
98
|
+
# config/initializers/unidom.rb
|
|
99
|
+
Unidom::Common.configure do |options|
|
|
100
|
+
|
|
101
|
+
options[:neglected_namespaces] = %w{
|
|
102
|
+
Unidom::Category
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
end
|
|
106
|
+
```
|
|
@@ -13,12 +13,8 @@ class Unidom::Category::Categorizing < Unidom::Category::ApplicationRecord
|
|
|
13
13
|
scope :category_is, ->(category) { where category_id: to_id(category) }
|
|
14
14
|
scope :categorized_is, ->(categorized) { where categorized: categorized }
|
|
15
15
|
|
|
16
|
-
#def self.categorize!(category, categorized, opened_at = Time.now)
|
|
17
|
-
# self.categorized_is(categorized).category_is(category).valid_at.alive.first_or_create! elemental: true, opened_at: opened_at
|
|
18
|
-
#end
|
|
19
|
-
|
|
20
16
|
def self.categorize!(categorized, into: nil, at: Time.now)
|
|
21
17
|
categorized_is(categorized).category_is(into).valid_at.alive.first_or_create! elemental: true, opened_at: at
|
|
22
18
|
end
|
|
23
19
|
|
|
24
|
-
end
|
|
20
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Categorizing'
|
|
@@ -19,4 +19,4 @@ class Unidom::Category::Category < Unidom::Category::ApplicationRecord
|
|
|
19
19
|
scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length }
|
|
20
20
|
scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' }
|
|
21
21
|
|
|
22
|
-
end
|
|
22
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Category'
|
|
@@ -29,8 +29,11 @@ class Unidom::Category::CategoryRollup < Unidom::Category::ApplicationRecord
|
|
|
29
29
|
end
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
##
|
|
33
|
+
# 将 it 归为 into 的下级分类,时间是 at ,缺省为当前时间。如:
|
|
34
|
+
# Unidom::Category::CategoryRollup.roll_up! moto, into: vehicle
|
|
32
35
|
def self.roll_up!(it, into: nil, at: Time.now)
|
|
33
36
|
self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
end
|
|
39
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryRollup'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unidom-category
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.5
|
|
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-01-
|
|
11
|
+
date: 2017-01-22 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.9'
|
|
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.9'
|
|
27
27
|
description: Unidom (UNIfied Domain Object Model) is a series of domain model engines.
|
|
28
28
|
The Category domain model engine includes Category and its relative models. Unidom
|
|
29
29
|
(统一领域对象模型)是一系列的领域模型引擎。类别领域模型引擎包括类别及其相关的模型。
|