Commit 83cacd72 by Derrick Reimer

JRuby compatibility

By default, ObjectSpace.each_object is disabled in JRuby. However, ObjectSpace.each_object(Class) still works.
parent bef0c494
...@@ -316,11 +316,8 @@ module AnnotateModels ...@@ -316,11 +316,8 @@ module AnnotateModels
# Retrieve loaded model class by path to the file where it's supposed to be defined. # Retrieve loaded model class by path to the file where it's supposed to be defined.
def get_loaded_model(model_path) def get_loaded_model(model_path)
ObjectSpace.each_object. ObjectSpace.each_object(::Class).
select { |c| select { |c| c.ancestors.include?(ActiveRecord::Base) }.
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
c.ancestors.include?(ActiveRecord::Base)
}.
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path } detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment