unidom-category 1.4 → 1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e616b1c45ec60ec69bbd13ec315c19cf3ecc2a10
|
4
|
+
data.tar.gz: af7eb47899e2707782119ed136cae02fd3c6846e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 319e5f50d915c6f165c1ccc970f0917b36115d24b6280b21db8310204e5e60d9d288c6e9e0ae19660cda951d46bab16f19a35452fe16d438d8fdd4654da37d47
|
7
|
+
data.tar.gz: 2f2113742c8131fc318940ab3ea341cdef83162bcccc8c61aa87ca3dcc585e7d03c5f267a07d81fdc0763b21936b52759dff6594e1883a7c09c2c89f00e696db
|
data/README.md
CHANGED
@@ -75,12 +75,14 @@ The As Categorized concern do the following tasks for the includer automatically
|
|
75
75
|
|
76
76
|
The As Ancestor Category concern do the following tasks for the includer automatically:
|
77
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``
|
78
|
+
2. Define the has_many :descendant_categories macro as: ``has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups``
|
79
79
|
3. Define the #roll_up! method as: ``roll_up!(it, at: Time.now, primary: true)``
|
80
|
+
4. Define the #roll_up? method as: ``roll_up?(it, at: Time.now, primary: true)``
|
80
81
|
|
81
82
|
### As Descendant Category concern
|
82
83
|
|
83
84
|
The As Descendant Category concern do the following tasks for the includer automatically:
|
84
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``
|
85
|
-
2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
|
86
|
+
2. Define the has_many :ancestor_categories macro as: ``has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups``
|
86
87
|
3. Define the #is_rolled_up! as: ``is_rolled_up!(it, at: Time.now, primary: true)``
|
88
|
+
4. Define the #is_rolled_up? as: ``is_rolled_up?(it, at: Time.now, primary: true)``
|
@@ -28,12 +28,8 @@ class Unidom::Category::CategoryRollup < ActiveRecord::Base
|
|
28
28
|
end
|
29
29
|
}
|
30
30
|
|
31
|
-
def self.roll_up!(
|
32
|
-
self.descendant_category_is(
|
31
|
+
def self.roll_up!(it, into: nil, at: Time.now)
|
32
|
+
self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
|
33
33
|
end
|
34
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
35
|
end
|
@@ -14,9 +14,9 @@ module Unidom::Category::Concerns::AsAncestorCategory
|
|
14
14
|
rollup
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
|
21
21
|
end
|
22
22
|
|
@@ -14,9 +14,9 @@ module Unidom::Category::Concerns::AsDescendantCategory
|
|
14
14
|
rollup
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
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
20
|
|
21
21
|
end
|
22
22
|
|
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.
|
4
|
+
version: '1.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: 2016-10-
|
11
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|