closure_tree 4.2.7 → 4.2.8
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 +9 -9
- data/README.md +5 -2
- data/lib/closure_tree/support.rb +5 -1
- data/lib/closure_tree/support_flags.rb +1 -1
- data/lib/closure_tree/version.rb +1 -1
- data/spec/db/schema.rb +13 -0
- data/spec/metal_spec.rb +9 -0
- data/spec/support/models.rb +6 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzZlMDU1MWEzOWIyM2RlMDAxNWQwNmE3YjZiMDU0NTY3ZmE5YzQ5Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
ODc3MzBlMDhlZDY2YTk0OWY5YzZhODkxZmExNDRiMDBiMDE0ODdkMA==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzJjMjU5Zjc0MzhmNThmNTI1YmQ4MTAyNGRkMGE4NTk4NGYyZWUyY2ZhNDE2
|
10
|
+
ZDc3OTdlNGI4NzMzMDBjZjJjY2VkZDY3ZmI5MmJiNzk1ZWZkYTUxZTEyOTVi
|
11
|
+
YjM0MmZjNDQ5NDEzNjk1NTgzNGQ1ZTk1MDI1ZGI3MzQ4YzMyMjU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDgyZjg5MTU5NzAyNmIwZDMyZWI5N2QyYmZhYjhjZTVjNWQ4NGY5MWMyMjY5
|
14
|
+
ZDc2M2QwNzcxOTkzYjE4MWQzZTYxYjllNDQ2ZjUyZTY3Y2ZkYjRlMTZkNGVk
|
15
|
+
YTNhNGFiNTM4ZGNjMzVlMmU0ZTM1NTVhZjNiNWIxZTEwMzUxNjU=
|
data/README.md
CHANGED
@@ -59,7 +59,10 @@ Note that closure_tree only supports Rails 3.0 and later, and has test coverage
|
|
59
59
|
|
60
60
|
2. Run ```bundle install```
|
61
61
|
|
62
|
-
3. Add ```acts_as_tree``` to your hierarchical model(s).
|
62
|
+
3. Add ```acts_as_tree``` to your hierarchical model(s).
|
63
|
+
Make sure you add ```acts_as_tree``` *after any ```attr_accessible``` and ```self.table_name =```
|
64
|
+
lines in your model.
|
65
|
+
Please review the [available options](#available-options) you can provide.
|
63
66
|
|
64
67
|
4. Add a migration to add a ```parent_id``` column to the model you want to act_as_tree.
|
65
68
|
You may want to also [add a column for deterministic ordering of children](#sort_order), but that's optional.
|
@@ -93,7 +96,7 @@ Note that closure_tree only supports Rails 3.0 and later, and has test coverage
|
|
93
96
|
:unique => true, :name => "tag_anc_desc_udx"
|
94
97
|
|
95
98
|
# For "all ancestors of…" selects,
|
96
|
-
add_index :tag_hierarchies, [:descendant_id]
|
99
|
+
add_index :tag_hierarchies, [:descendant_id],
|
97
100
|
:name => "tag_desc_idx"
|
98
101
|
end
|
99
102
|
end
|
data/lib/closure_tree/support.rb
CHANGED
@@ -68,7 +68,11 @@ module ClosureTree
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def scope_with_order(scope, additional_order_by = nil)
|
71
|
-
order_option?
|
71
|
+
if order_option?
|
72
|
+
scope.order(*([additional_order_by, order_by].compact))
|
73
|
+
else
|
74
|
+
additional_order_by ? scope.order(additional_order_by) : scope
|
75
|
+
end
|
72
76
|
end
|
73
77
|
|
74
78
|
# lambda-ize the order, but don't apply the default order_option
|
@@ -4,7 +4,7 @@ module ClosureTree
|
|
4
4
|
def use_attr_accessible?
|
5
5
|
defined?(ActiveModel::MassAssignmentSecurity) &&
|
6
6
|
model_class.respond_to?(:accessible_attributes) &&
|
7
|
-
model_class.accessible_attributes.
|
7
|
+
! model_class.accessible_attributes.nil?
|
8
8
|
end
|
9
9
|
|
10
10
|
def include_forbidden_attributes_protection?
|
data/lib/closure_tree/version.rb
CHANGED
data/spec/db/schema.rb
CHANGED
@@ -106,4 +106,17 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
106
106
|
t.integer "descendant_id", :null => false
|
107
107
|
t.integer "generations", :null => false
|
108
108
|
end
|
109
|
+
|
110
|
+
create_table "metal", :force => true do |t|
|
111
|
+
t.integer "parent_id"
|
112
|
+
t.string "metal_type"
|
113
|
+
t.string "value"
|
114
|
+
t.integer "sort_order"
|
115
|
+
end
|
116
|
+
|
117
|
+
create_table "metal_hierarchies", :id => false, :force => true do |t|
|
118
|
+
t.integer "ancestor_id", :null => false
|
119
|
+
t.integer "descendant_id", :null => false
|
120
|
+
t.integer "generations", :null => false
|
121
|
+
end
|
109
122
|
end
|
data/spec/metal_spec.rb
ADDED
data/spec/support/models.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: closure_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew McEachen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -207,6 +207,7 @@ files:
|
|
207
207
|
- spec/db/schema.rb
|
208
208
|
- spec/fixtures/tags.yml
|
209
209
|
- spec/label_spec.rb
|
210
|
+
- spec/metal_spec.rb
|
210
211
|
- spec/namespace_type_spec.rb
|
211
212
|
- spec/parallel_prepend_sibling_spec.rb
|
212
213
|
- spec/parallel_spec.rb
|
@@ -237,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
238
|
version: '0'
|
238
239
|
requirements: []
|
239
240
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.1.5
|
241
242
|
signing_key:
|
242
243
|
specification_version: 4
|
243
244
|
summary: Easily and efficiently make your ActiveRecord model support hierarchies
|
@@ -247,6 +248,7 @@ test_files:
|
|
247
248
|
- spec/db/schema.rb
|
248
249
|
- spec/fixtures/tags.yml
|
249
250
|
- spec/label_spec.rb
|
251
|
+
- spec/metal_spec.rb
|
250
252
|
- spec/namespace_type_spec.rb
|
251
253
|
- spec/parallel_prepend_sibling_spec.rb
|
252
254
|
- spec/parallel_spec.rb
|