From: "trans. (T. Onoma)" Date: 2004-12-03T11:22:08+09:00 Subject: TopLevel Delegate Hi -- I'm trying to delegate the TOPLEVEL object through a singleton class, but it doesn't seem to want to "singularize". I've tried the Singleton module and manually as below. When I run this: assert_equal( toplevel , toplevel ) I get 1) Failure: test_compare(TC_TopLevel) [tc_toplevel.rb:16]:
expected but was
. Any ideas? Thanks, T. # toplevel.rb ------------------------------------------- class Binding def eval( str ) Kernel.eval( str, self ) end def self() @self ||= eval( "self" ) @self end end #require 'singleton' require 'delegate' class TopLevelClass < DelegateClass(TOPLEVEL_BINDING.self.class) #include Singleton class << self private :new def instance @singleton ||= new end end def initialize() super( TOPLEVEL_BINDING.self ) end def binding() TOPLEVEL_BINDING end end module Kernel # perhaps just call this top() ? def toplevel() TopLevelClass.instance end end