ancestry 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ancestry/has_ancestry.rb +16 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 005c1204eb8018577673e708da755c1e8b0ae388
|
4
|
+
data.tar.gz: 7f55187582a5d94339dd86e972ec9070c9cf1fed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 568208af2c3eb95eca4b71ceed135c72743370ff60e7d1209f5b1a5ef7557ef379680ccdf5a83dc5b80323a403c422d3b14501b41fc0d01557a53d4d04170a51
|
7
|
+
data.tar.gz: 1b8c1b91c87573b7d9e611df92bb185bbb9712964a3dc0f64ccda3bde6c17fe11dd358212bdbb2f76645915723a66d179570ee4eb1ef630f96558f1f1ea043d9
|
@@ -43,13 +43,22 @@ class << ActiveRecord::Base
|
|
43
43
|
scope :descendants_of, lambda { |object| where(to_node(object).descendant_conditions) }
|
44
44
|
scope :subtree_of, lambda { |object| where(to_node(object).subtree_conditions) }
|
45
45
|
scope :siblings_of, lambda { |object| where(to_node(object).sibling_conditions) }
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
scope :ordered_by_ancestry, lambda {
|
47
|
+
if %w(mysql mysql2 sqlite postgresql).include?(connection.adapter_name.downcase) &&
|
48
|
+
defined?(ActiveRecord.version) && ActiveRecord.version.to_s >= "5"
|
49
|
+
reorder("coalesce(#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}, '')")
|
50
|
+
else
|
51
|
+
reorder("(CASE WHEN #{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)} IS NULL THEN 0 ELSE 1 END), #{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}")
|
52
|
+
end
|
53
|
+
}
|
54
|
+
scope :ordered_by_ancestry_and, lambda { |order|
|
55
|
+
if %w(mysql mysql2 sqlite postgresql).include?(connection.adapter_name.downcase) &&
|
56
|
+
defined?(ActiveRecord.version) && ActiveRecord.version.to_s >= "5"
|
57
|
+
reorder("coalesce(#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}, ''), #{order}")
|
58
|
+
else
|
59
|
+
reorder("(CASE WHEN #{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)} IS NULL THEN 0 ELSE 1 END), #{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}, #{order}")
|
60
|
+
end
|
61
|
+
}
|
53
62
|
scope :path_of, lambda { |object| to_node(object).path }
|
54
63
|
|
55
64
|
# Update descendants with new ancestry before save
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ancestry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kroes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|