Skip to content

Commit 83cacd7

Browse files
committed
JRuby compatibility
By default, ObjectSpace.each_object is disabled in JRuby. However, ObjectSpace.each_object(Class) still works.
1 parent bef0c49 commit 83cacd7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/annotate/annotate_models.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,8 @@ def get_model_class(file)
316316

317317
# Retrieve loaded model class by path to the file where it's supposed to be defined.
318318
def get_loaded_model(model_path)
319-
ObjectSpace.each_object.
320-
select { |c|
321-
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
322-
c.ancestors.include?(ActiveRecord::Base)
323-
}.
319+
ObjectSpace.each_object(::Class).
320+
select { |c| c.ancestors.include?(ActiveRecord::Base) }.
324321
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
325322
end
326323

0 commit comments

Comments
 (0)