[Nitro] Patch: Unsuccesful target resolving
Aleksi Niemela
Aleksi.Niemela at cs.helsinki.fi
Sun Jun 19 05:09:14 EDT 2005
When code points to a class that doesn't exist Og ends up looping
indefinitely.
class User
property :name, String
# has_many :preferences, :Preference # assuming class
Preference exist this would work
has_many :preferences, :Preference_typo # hangs Og
end
Here's a patch. It assumes there wouldn't be more than 10 levels of
retries (actually I didn't understand for what is the retry for, but
still the patch worked for me :).
- Aleksi
$ diff -u relation.rb~ relation.rb
--- relation.rb~ 2005-06-13 23:54:27.535000000 +0300
+++ relation.rb 2005-06-19 12:04:11.187500000 +0300
@@ -72,10 +72,15 @@
c = "::" + c unless c =~ /::/
c.gsub!(/::.*$/, '::')
c << target_class.to_s
+ retries = 0
begin
klass = constant(c)
rescue
c = target_class
+ retries += 1
+ if retries > 10
+ raise "Couldn't resolve target:
#{target_class.to_s} for #{owner_class.name.dup}"
+ end
retry
end
@options[:target_class] = klass
More information about the Nitro-general
mailing list