closure_tree 9.1.1 → 9.2.0
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/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/lib/closure_tree/support.rb +16 -2
- data/lib/closure_tree/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ace270a69b46da9e3ba8594cb5299e0eb3d9b222f3261c6304566cdbe1f5c7bd
|
4
|
+
data.tar.gz: ea4dccd196cf9278d510f89fa62d5e892916f2effa82b9c08cf851305523d528
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f915001574717ed1bbadf7f528a6d8d04aa1143cf3ca736db3c1649e72cf4e0d3a60303df86456b6f5ab86a8b1a819987475361a6497f2488f3768ff243dc68
|
7
|
+
data.tar.gz: 865de6b37ea0db45a27852799e2853b37091f32e06e28a405123e429275a05c7591069039f878cf26f6064e0e5d58ad67c9d227ef8911c2092667f009b4610f5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [9.2.0](https://github.com/ClosureTree/closure_tree/compare/closure_tree/v9.1.1...closure_tree/v9.2.0) (2025-10-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* add PostgreSQL schema-qualified table name support ([#462](https://github.com/ClosureTree/closure_tree/issues/462)) ([5f9006c](https://github.com/ClosureTree/closure_tree/commit/5f9006cece95a76f665cb50c2615317e3fa48586))
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* add implicit_order_column for Rails 8.1+ compatibility ([#464](https://github.com/ClosureTree/closure_tree/issues/464)) ([f384303](https://github.com/ClosureTree/closure_tree/commit/f38430334a79ea15d236f9212118dcb5e4530746))
|
14
|
+
|
3
15
|
## [9.1.1](https://github.com/ClosureTree/closure_tree/compare/closure_tree/v9.1.0...closure_tree/v9.1.1) (2025-07-24)
|
4
16
|
|
5
17
|
|
data/README.md
CHANGED
@@ -343,7 +343,7 @@ When you include ```has_closure_tree``` in your model, you can provide a hash to
|
|
343
343
|
* ```tag.child?``` returns true if this is a child node. It has a parent.
|
344
344
|
* ```tag.leaf?``` returns true if this is a leaf node. It has no children.
|
345
345
|
* ```tag.leaves``` is scoped to all leaf nodes in self_and_descendants.
|
346
|
-
* ```tag.depth``` returns the depth, or "generation", for this node in the tree. A root node will have a value of 0.
|
346
|
+
* ```tag.depth``` returns the depth, or "generation", for this node in the tree. A root node will have a value of 0. Also aliased as `level`.
|
347
347
|
* ```tag.parent``` returns the node's immediate parent. Root nodes will return nil.
|
348
348
|
* ```tag.parent_of?(node)``` returns true if current node is parent of another one
|
349
349
|
* ```tag.children``` is a ```has_many``` of immediate children (just those nodes whose parent is the current node).
|
data/lib/closure_tree/support.rb
CHANGED
@@ -33,6 +33,9 @@ module ClosureTree
|
|
33
33
|
hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(model_class.superclass))
|
34
34
|
model_class_name = model_class.to_s
|
35
35
|
hierarchy_class.class_eval do
|
36
|
+
# Rails 8.1+ requires an implicit_order_column for models without a primary key
|
37
|
+
self.implicit_order_column = 'ancestor_id'
|
38
|
+
|
36
39
|
belongs_to :ancestor, class_name: model_class_name
|
37
40
|
belongs_to :descendant, class_name: model_class_name
|
38
41
|
def ==(other)
|
@@ -51,8 +54,19 @@ module ClosureTree
|
|
51
54
|
# We need to use the table_name, not something like ct_class.to_s.demodulize + "_hierarchies",
|
52
55
|
# because they may have overridden the table name, which is what we want to be consistent with
|
53
56
|
# in order for the schema to make sense.
|
54
|
-
|
55
|
-
|
57
|
+
if options[:hierarchy_table_name]
|
58
|
+
tablename = options[:hierarchy_table_name]
|
59
|
+
else
|
60
|
+
base_table = remove_prefix_and_suffix(table_name, model_class)
|
61
|
+
|
62
|
+
# Handle PostgreSQL schema-qualified table names (e.g., "my_schema.table_name")
|
63
|
+
schema, _, table = base_table.rpartition('.')
|
64
|
+
if schema.present?
|
65
|
+
tablename = "#{schema}.#{table.singularize}_hierarchies"
|
66
|
+
else
|
67
|
+
tablename = "#{table.singularize}_hierarchies"
|
68
|
+
end
|
69
|
+
end
|
56
70
|
|
57
71
|
[model_class.table_name_prefix, tablename, model_class.table_name_suffix].join
|
58
72
|
end
|
data/lib/closure_tree/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closure_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.
|
4
|
+
version: 9.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew McEachen
|
@@ -178,7 +178,7 @@ licenses:
|
|
178
178
|
metadata:
|
179
179
|
bug_tracker_uri: https://github.com/ClosureTree/closure_tree/issues
|
180
180
|
changelog_uri: https://github.com/ClosureTree/closure_tree/blob/master/CHANGELOG.md
|
181
|
-
documentation_uri: https://www.rubydoc.info/gems/closure_tree/9.
|
181
|
+
documentation_uri: https://www.rubydoc.info/gems/closure_tree/9.2.0
|
182
182
|
homepage_uri: https://closuretree.github.io/closure_tree/
|
183
183
|
source_code_uri: https://github.com/ClosureTree/closure_tree
|
184
184
|
rubygems_mfa_required: 'true'
|