unidom-category 1.3 → 1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f08019b4625520f38401076dfeecb7ae9554896
4
- data.tar.gz: 6878e743ac7038c34d8129750ae784581db78c0c
3
+ metadata.gz: 57cc5460c2f1067539f7fef4c2e320f42d07159b
4
+ data.tar.gz: 78b0cca4a7599d517d661ccadc7ac9a1d20cfc88
5
5
  SHA512:
6
- metadata.gz: e40165eaf0cd8a1314e9545c11de4ab734645603817af4dd171400e2352dfe30fd6117f9540c144b5eb9b6be3a48e19bd8d0191f799dd60dd01722a74a115071
7
- data.tar.gz: 202be75deddd9cc57e4e6f3affbe50b778113154227dc8d83e8d5cb5390862bd496fc37d4031f37ebd51439b4dd3b1d7ff0aa94202dc2d66b71f3b21bf400030
6
+ metadata.gz: 5e49f397ef5af6e9f18de3fba2894428a7942031fb17b45ca4b5e630fb2db35cbfef1b2b20c9928430c879a7574542deed4f3c86bf51fc6c76e1ef704c6d7790
7
+ data.tar.gz: 7324aab9be40d6620756b719687595c9840f566173086f9d6ae55560cb35eea4df4cdf86c43286238f55b2824bd7ed9ce2f80e15fe7a47a3dd2b2ff807625cf9
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-category.svg)](https://badge.fury.io/rb/unidom-category)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/unidom-category.svg)](https://gemnasium.com/github.com/topbitdu/unidom-category)
5
6
 
6
7
  Unidom (UNIfied Domain Object Model) is a series of domain model engines. The Category domain model engine includes Category and its relative models.
7
8
  Unidom (统一领域对象模型)是一系列的领域模型引擎。类别领域模型引擎包括类别及其相关的模型。
@@ -9,6 +10,7 @@ Unidom (统一领域对象模型)是一系列的领域模型引擎。类别领
9
10
 
10
11
 
11
12
  ## Recent Update
13
+
12
14
  Check out the [Road Map](ROADMAP.md) to find out what's the next.
13
15
  Check out the [Change Log](CHANGELOG.md) to find out what's new.
14
16
 
@@ -55,12 +57,14 @@ include Unidom::Category::Concerns::AsDescendantCategory
55
57
  ```
56
58
 
57
59
  ### As Category concern
60
+
58
61
  The As Category concern do the following tasks for the includer automatically:
59
62
  1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Category::Categorizing'``
60
63
  2. Define the #categorize! method as: ``categorize!(categorized, at: Time.now, primary: true)``
61
64
  3. Define the #categorize? method as: ``categorize?(categorized, at: Time.now, primary: true)``
62
65
 
63
66
  ### As Categorized concern
67
+
64
68
  The As Categorized concern do the following tasks for the includer automatically:
65
69
  1. Define the has_many :categorizings macro as: ``has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized``
66
70
  2. Define the has_many :categories macro as: ``has_many :categories, through: :categorizings, source: :category``
@@ -68,11 +72,15 @@ The As Categorized concern do the following tasks for the includer automatically
68
72
  4. Define the #is_categorized? method as: ``is_categorized?(into: nil, at: Time.now, primary: true)``
69
73
 
70
74
  ### As Ancestor Category concern
75
+
71
76
  The As Ancestor Category concern do the following tasks for the includer automatically:
72
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``
73
- 2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
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)``
74
80
 
75
81
  ### As Descendant Category concern
82
+
76
83
  The As Descendant Category concern do the following tasks for the includer automatically:
77
84
  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``
78
- 2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
85
+ 2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
86
+ 3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
@@ -28,12 +28,12 @@ class Unidom::Category::CategoryRollup < ActiveRecord::Base
28
28
  end
29
29
  }
30
30
 
31
- #def self.roll_up!(ancestor_category, descendant_category, opened_at = Time.now)
32
- # self.descendant_category_is(descendant_category).ancestor_category_is(ancestor_category).valid_at.alive.first_or_create! opened_at: opened_at
33
- #end
34
-
35
31
  def self.roll_up!(descendant_category, into: nil, at: Time.now)
36
32
  self.descendant_category_is(descendant_category).ancestor_category_is(into).valid_at.alive.first_or_create! opened_at: at
37
33
  end
38
34
 
35
+ #def self.roll_up!(it, into: nil, at: Time.now)
36
+ # self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
37
+ #end
38
+
39
39
  end
@@ -7,6 +7,17 @@ module Unidom::Category::Concerns::AsAncestorCategory
7
7
  has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category
8
8
  has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups
9
9
 
10
+ def roll_up!(it, at: Time.now, primary: true)
11
+ rollup = descendant_category_rollups.descendant_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
+ rollup.elemental = primary if rollup.elemental!=primary
13
+ rollup.save!
14
+ rollup
15
+ end
16
+
17
+ #def roll_up?(it, at: Time.now, primary: true)
18
+ # descendant_category_rollups.descendant_category_is(it).primary(primary).valid_at(now: at).alive.exists?
19
+ #end
20
+
10
21
  end
11
22
 
12
23
  module ClassMethods
@@ -7,6 +7,17 @@ module Unidom::Category::Concerns::AsDescendantCategory
7
7
  has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category
8
8
  has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups
9
9
 
10
+ def is_rolled_up!(it, at: Time.now, primary: true)
11
+ rollup = ancestor_category_rollups.ancestor_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
+ rollup.elemental = primary if rollup.elemental!=primary
13
+ rollup.save!
14
+ rollup
15
+ end
16
+
17
+ #def is_rolled_up?(it, at: Time.now, primary: true)
18
+ # ancestor_category_rollups.ancestor_category_is(it).primary(primary).valid_at(now: at).alive.exists?
19
+ #end
20
+
10
21
  end
11
22
 
12
23
  module ClassMethods
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Category
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-category
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-01 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