From: Levin Alexander Date: 2005-07-08T01:38:24+09:00 Subject: Struct-like behaviour in custom classes Hi, How can I build a Class that works like the built-in "Struct" and returns new anonymous classes based on arguments to MyClass.new? A simplified example: with_foo = MyClass.new(:foo) one = with_foo.new one.foo with_bar = MyClass.new(:bar) two = with_bar.new two.bar I tried to do: class MyClass def self.new_class(method_name) c = Class.new(self) c.class_eval do define_method(method_name) { puts "method #{method_name} called" } end return c end end How can I rename 'new_class' to 'new' without breaking 'new' in derieved classes? Thank You, Levin