Skip to content
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

Call Module#module_parent instead of deprecated #parent #349

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion gemfiles/activerecord_4.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem "activerecord", "~> 4.2.0"
platforms :ruby do
gem "mysql2", "< 0.5"
gem "pg", "~> 0.21"
gem "sqlite3"
gem "sqlite3", "~> 1.3", "< 1.4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these gemfiles have been fixed at their source in appraisals.

Could you remove the changes to the gemfiles from this PR and ensure that the tests work for you?

end

platforms :jruby do
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/activerecord_5.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gem "activerecord", "~> 5.0.0"
platforms :ruby do
gem "mysql2"
gem "pg"
gem "sqlite3"
gem "sqlite3", "~> 1.3", "< 1.4"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, remove this one too

end

platforms :jruby do
Expand Down
7 changes: 6 additions & 1 deletion lib/closure_tree/support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def initialize(model_class, options)
end

def hierarchy_class_for_model
hierarchy_class = model_class.parent.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base))
parent_class = if ActiveSupport.version >= Gem::Version.new('6.0.0.beta1')
Copy link
Contributor

@kbrock kbrock Sep 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may want to to_s for the comparison - it simplifies things

Also, rails 6.0 has been released, so probably want to fix that too

Suggested change
parent_class = if ActiveSupport.version >= Gem::Version.new('6.0.0.beta1')
parent_class = if ActiveSupport.version.to_s >= "6.0.0"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also be

Suggested change
parent_class = if ActiveSupport.version >= Gem::Version.new('6.0.0.beta1')
parent_class = if ActiveSupport::VERSION::MAJOR >= 6

model_class.module_parent
else
model_class.parent
end
hierarchy_class = parent_class.const_set(short_hierarchy_class_name, Class.new(ActiveRecord::Base))
use_attr_accessible = use_attr_accessible?
include_forbidden_attributes_protection = include_forbidden_attributes_protection?
model_class_name = model_class.to_s
Expand Down