From 3bfd2f87fb5edbf8be72c28271b4dfa534a00aac Mon Sep 17 00:00:00 2001 From: iamtheschmitzer Date: Fri, 27 Apr 2018 10:55:03 -0500 Subject: [PATCH 1/2] Fix assigned but unused variable warning --- lib/closure_tree/support.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/closure_tree/support.rb b/lib/closure_tree/support.rb index d464f675..6424ede1 100644 --- a/lib/closure_tree/support.rb +++ b/lib/closure_tree/support.rb @@ -34,10 +34,11 @@ def hierarchy_class_for_model hierarchy_class = model_class.parent.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base)) use_attr_accessible = use_attr_accessible? include_forbidden_attributes_protection = include_forbidden_attributes_protection? - hierarchy_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + model_class_name = model_class.to_s + hierarchy_class.class_eval do include ActiveModel::ForbiddenAttributesProtection if include_forbidden_attributes_protection - belongs_to :ancestor, :class_name => "#{model_class}" - belongs_to :descendant, :class_name => "#{model_class}" + belongs_to :ancestor, class_name: model_class_name + belongs_to :descendant, class_name: model_class_name attr_accessible :ancestor, :descendant, :generations if use_attr_accessible def ==(other) self.class == other.class && ancestor_id == other.ancestor_id && descendant_id == other.descendant_id @@ -46,7 +47,7 @@ def ==(other) def hash ancestor_id.hash << 31 ^ descendant_id.hash end - RUBY + end hierarchy_class.table_name = hierarchy_table_name hierarchy_class end From f26c45b6a6c4b1a707f226b627c5356a7099d60b Mon Sep 17 00:00:00 2001 From: iamtheschmitzer Date: Thu, 20 Sep 2018 10:30:00 -0500 Subject: [PATCH 2/2] Fix assigned but unused variable Possibly was intended to be keyword arguments? --- lib/closure_tree/support_attributes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/closure_tree/support_attributes.rb b/lib/closure_tree/support_attributes.rb index 2c6ae255..43ab4262 100644 --- a/lib/closure_tree/support_attributes.rb +++ b/lib/closure_tree/support_attributes.rb @@ -76,7 +76,7 @@ def order_by end def nulls_last_order_by - "-#{quoted_order_column} #{order_by_order(reverse = true)}" + "-#{quoted_order_column} #{order_by_order(true)}" end def order_by_order(reverse = false)