Skip to content

Fix unused variable warnings #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/closure_tree/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/closure_tree/support_attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down