Eloy Duran
eloy.****@gmail*****
Tue Jun 5 18:17:02 JST 2007
Hello guys, In revision 1816 I added the code to dynamically define a class when a ActiveRecord::Base subclass is defined. However at the moment the only way I could get this to work is by using old evil eval, but I would rather define it with Object.const_set(). If I use Object.const_set() I get the following error: /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_import.rb:323:in `objc_instance_method_type': no implicit conversion from nil to integer (TypeError) from /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_import.rb:323:in `_ns_enable_override?' from /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_import.rb:313:in `_ns_behavior_method_added' from /Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby/osx/objc/oc_import.rb:618:in `method_added' from tc_active_record.rb:39 The code: class ActiveRecord::Base class << self alias_method :__inherited_before_proxy__, :inherited def inherited(klass) proxy_klass = "#{klass.to_s}Proxy" unless Object.const_defined?(proxy_klass) # eval "class ::#{proxy_klass} < OSX::ActiveRecordProxy; end;" # FIXME: This leads to a TypeError originating from: oc_import.rb:618:in `method_added' Object.const_set(proxy_klass, Class.new(OSX::ActiveRecordProxy)) end self.__inherited_before_proxy__(klass) end end end Could somebody explain to me why this error occurs? Cheers, Eloy