From: Ed Sinjiashvili Date: 2002-04-01T20:59:59+09:00 Subject: Re: re-extending object ts writes: > Why you don't use a State pattern ? Thanx for the snippet, I used similar scheme, but without automated #method_missing dispath. Still my question was - Could I use *Module* mixins to implement that pattern? > In your case a *STUPID* implementation Is it stupid to expect that mixin will override methods that already present in the object? Or is it stupid to use #extend - 'cause it can be used more than once per mixin? whailer% cat stupid.rb module A def a() puts "A#a" end def b() puts "A#b" end end module B def b() puts "B#b" end def c() puts "B#c" end end module C def c() puts "C#c" end def a() puts "C#a" end end a = Object.new a.extend A a.a; a.b; puts a.extend B a.a; a.b; a.c; puts a.extend C a.a; a.b; a.c; puts a.extend A # stupid??? a.a; a.b; a.c whailer% whailer% ruby stupid.rb A#a A#b A#a B#b B#c C#a B#b C#c C#a B#b C#c whailer% --Ed