Skip to content

Commit 0095093

Browse files
iamtheschmitzerseuros
authored andcommitted
Fix unused variable warnings (#327)
* Fix assigned but unused variable warnings
1 parent 1bc10c8 commit 0095093

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/closure_tree/support.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ def hierarchy_class_for_model
3535
hierarchy_class = model_class.parent.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base))
3636
use_attr_accessible = use_attr_accessible?
3737
include_forbidden_attributes_protection = include_forbidden_attributes_protection?
38-
hierarchy_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
38+
model_class_name = model_class.to_s
39+
hierarchy_class.class_eval do
3940
include ActiveModel::ForbiddenAttributesProtection if include_forbidden_attributes_protection
40-
belongs_to :ancestor, :class_name => "#{model_class}"
41-
belongs_to :descendant, :class_name => "#{model_class}"
41+
belongs_to :ancestor, class_name: model_class_name
42+
belongs_to :descendant, class_name: model_class_name
4243
attr_accessible :ancestor, :descendant, :generations if use_attr_accessible
4344
def ==(other)
4445
self.class == other.class && ancestor_id == other.ancestor_id && descendant_id == other.descendant_id
@@ -47,7 +48,7 @@ def ==(other)
4748
def hash
4849
ancestor_id.hash << 31 ^ descendant_id.hash
4950
end
50-
RUBY
51+
end
5152
hierarchy_class.table_name = hierarchy_table_name
5253
hierarchy_class
5354
end

lib/closure_tree/support_attributes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def dont_order_roots
8080
end
8181

8282
def nulls_last_order_by
83-
"-#{quoted_order_column} #{order_by_order(reverse = true)}"
83+
"-#{quoted_order_column} #{order_by_order(true)}"
8484
end
8585

8686
def order_by_order(reverse = false)

0 commit comments

Comments
 (0)