closure_tree 4.2.7 → 4.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWUwYTFjNDQ4ZDI3ZDhkZTc0MWU1ZmY4MDZkZmMxZDdjZjY3MmFjMw==
4
+ NzZlMDU1MWEzOWIyM2RlMDAxNWQwNmE3YjZiMDU0NTY3ZmE5YzQ5Mw==
5
5
  data.tar.gz: !binary |-
6
- YzdmYTU0ZDNkODUyOGNkNTMyZDE4YTQ4ZTg3MzY4ZTRhMzhjZTllZA==
7
- !binary "U0hBNTEy":
6
+ ODc3MzBlMDhlZDY2YTk0OWY5YzZhODkxZmExNDRiMDBiMDE0ODdkMA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDMxNjQxNjYxZGYyNDMxNjM5MDhmZGQ0MzMyYTI4ZDU3ZWUwZmIwYjk1NTBj
10
- ZTQ0N2YwYTIwMWYzNGQ2MDAwYTQ1MjBiM2MyMmNjZTY3ZTNiNTJkNWI1NWE2
11
- NzQ4MDMxODYzMGQ1YTkxN2VkNTE3YjU2NTI0ZDQ0ODZkOGNlODE=
9
+ MzJjMjU5Zjc0MzhmNThmNTI1YmQ4MTAyNGRkMGE4NTk4NGYyZWUyY2ZhNDE2
10
+ ZDc3OTdlNGI4NzMzMDBjZjJjY2VkZDY3ZmI5MmJiNzk1ZWZkYTUxZTEyOTVi
11
+ YjM0MmZjNDQ5NDEzNjk1NTgzNGQ1ZTk1MDI1ZGI3MzQ4YzMyMjU=
12
12
  data.tar.gz: !binary |-
13
- MzBjNmRmYmVlYWUzZjEyYjBlNjViNDEwYWVmOWU0ZTBmZGQwMWI2YTIzNGE4
14
- OWE3ZTcxNTBiMzk0OWYzZjliMzcxNzg0M2YxZWJiNzQ4OTYwYTFhN2ZjMjU3
15
- M2M1ZmUzOWVmMmFhMzgyZmIzNmVlNjgyNjExMjUyMzBkNDhkYmM=
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). There are a number of [options](#available-options) you can pass in, too.
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
@@ -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? ? scope.order(*([additional_order_by, order_by].compact)) : scope
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.present?
7
+ ! model_class.accessible_attributes.nil?
8
8
  end
9
9
 
10
10
  def include_forbidden_attributes_protection?
@@ -1,3 +1,3 @@
1
1
  module ClosureTree
2
- VERSION = Gem::Version.new("4.2.7") unless defined?(::ClosureTree::VERSION)
2
+ VERSION = Gem::Version.new('4.2.8') unless defined?(::ClosureTree::VERSION)
3
3
  end
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
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Metal do
4
+ it "creates" do
5
+ s = Metal.create(:value => 'System')
6
+ s.reload
7
+ s.should_not be_new_record
8
+ end
9
+ end
@@ -93,3 +93,9 @@ module Namespace
93
93
  attr_accessible :name if _ct.use_attr_accessible?
94
94
  end
95
95
  end
96
+
97
+ class Metal < ActiveRecord::Base
98
+ self.table_name = 'metal'
99
+ acts_as_tree :order => 'sort_order'
100
+ self.inheritance_column = 'metal_type'
101
+ end
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.7
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-07-21 00:00:00.000000000 Z
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.0.3
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