From: Tom Sawyer Date: 2003-01-06T06:18:13+09:00 Subject: Re: executing block at toplevel from within a class On Sunday 05 January 2003 08:01 am, nobu.nokada@softhome.net wrote: > No. Local variables (and constants now) are defined lexically. > You can add methods dynamically. thanks Nobu! that will work. refined: module Kernel def toplevel eval("self", TOPLEVEL_BINDING) end def metaclass_eval(&block) (class << self; self; end).class_eval(&block) end def define_singleton(meth, &block) metaclass_eval { define_method(meth, &block) } end end i have added this to tomslib/rubylib (new release coming soon). WARNING do not attempt: class PANIC def initialize toplevel.define_singleton(:lockup) { self } end end PANIC.new lockup i ran something like this via an apache/mod_ruby script and my machine locked up. your milage may vary, but i doubt it will be good milage in any case :) -transami