ancestry 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ancestry/has_ancestry.rb +16 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d611bf01715a442ecd16502afc11ad026f4bb40e
4
- data.tar.gz: 8f35de80e537902979302f933d969f9809164368
3
+ metadata.gz: 005c1204eb8018577673e708da755c1e8b0ae388
4
+ data.tar.gz: 7f55187582a5d94339dd86e972ec9070c9cf1fed
5
5
  SHA512:
6
- metadata.gz: d42e2cb51ccbebc16babbdc96f735391b41c1a0269fd3974139acfbdd95a38ce68995fcfbb515dc901b42339008d6053a60d881c51cf09ee95f0e631c4f0fff9
7
- data.tar.gz: 8309d979e01d4475b55aced74260db7829d09f81bcc567c7daac66d1b422bd63e77a8257b8e379651f309157a5d350bd7c00a80adfb7ad06d047d731314ceece
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
- if %w(mysql mysql2 sqlite postgresql).include?(connection.adapter_name.downcase)
47
- scope :ordered_by_ancestry, lambda { reorder("coalesce(#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}, '')") }
48
- scope :ordered_by_ancestry_and, lambda { |order| reorder("coalesce(#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(ancestry_column)}, ''), #{order}") }
49
- else
50
- scope :ordered_by_ancestry, lambda { 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)}") }
51
- scope :ordered_by_ancestry_and, lambda { |order| 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}") }
52
- end
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.1
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-10-25 00:00:00.000000000 Z
11
+ date: 2016-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord