On May 5, 2006, at 3:20 PM, Tanner Burson wrote: > After reading the sharp knives and glue thread, my head started > spinning > around some ways to minimize or localize the modifications to core > classes. > This is what I came up with, it's obviously rough, not-all- > inclusive, and > has some fairly obvious and severe drawbacks, but none-the-less I > thought > I'd share my 20 minutes of fiddling in the hopes of sparking some > conversation if nothing else. [...] Ruby does all that with #extend. module Meta attr_reader :something def self.extended(o) o.instance_variable_set :@something, 'Hello' end def test_meta puts 'Tested Meta!' end end > some_string = String.new > some_other_string = String.new > some_string.extend Meta > some_string.test_meta # -> "Tested Meta!" > puts some_string.something # -> "Hello" > > some_other_string.test_meta #--> "No method error" -- Eric Hodel - drbrain / segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com