Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
monkey-patching const_missing and friends
John Lam
9/15/2006 4:06:00 PM
In RubyCLR, I currently have a baseline dependency on ActiveRecord
because I need to patch const_missing *after* ActiveRecord does.So in
my top rubyclr.rb file it looks something like:
require 'rubygems'
require_gem 'ActiveRecord'
... lots of other requires for RubyCLR stuff.
require 'databinding'
Now, RubyCLR core doesn't have a dependency on databinding, only the
databinding 'extensions' do. I'd only like to drag in the dependency
on ActiveRecord when a user needs the databinding extensions, so I'd
like their program to look like:
require 'rubyclr'
require 'databinding'
to explicitly state their intent.
However, if I require ActiveRecord in the databinding module, it wipes
out my monkey patching of const_missing and friends (they're not
delegating properly, at least on the 1.3.1 local build that I have on
my dev box). The offending line of code is in dependencies.rb:123:
raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e)
They instead should be delegating to rails_original_const_missing instead.
Now, this isn't really the issue here - I'll report this bug through
the normal channels. Instead, it raises the larger issue of how to
co-exist with other libraries who might be doing 'bad' things like
this.
I *think* I'd like to re-run my core.rb file that monkey patches
everything after the offending library. My questions are:
1) Is this a good idea at all? (workarounds would be appreciated :)
2) How would I re-run my core.rb file? Would I read it in and then eval it?
Thanks
-John
http://www.iu...
(Contact me off-list via jlam@iunknown.com)
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
monkey-patching const_missing and friends
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password