On Nov 13, 2007, at 8:12 PM, Trans wrote:

> only question i have is about thread safety --could the instance var
> pose a potential problem with that?

probably.  maybe (untested):

cfp:~ > cat a.rb
class X
    class << self
      def ignoring_added_methods
        ignoring_added_methods = @ignoring_added_methods
        @ignoring_added_methods = true
        yield
      ensure
        @ignoring_added_methods = ignoring_added_methods
      end

      def ignoring_added_methods?
        defined? @ignoring_added_methods and @ignoring_added_methods
      end

      def method_added name
        Thread.critical = true
        return if ignoring_added_methods?
        ignoring_added_methods do
          p name
          define_method(:bar){}
        end
      ensure
        Thread.critical = false
      end
    end

     def foo
     end
end

cheers.


a @ http://codeforpeople.com/
--
it is not enough to be compassionate.  you must act.
h.h. the 14th dalai lama