From: Trans Date: 2006-07-16T19:40:10+09:00 Subject: Re: Save me from the method_missing Phil Tomson wrote: > So what is it exactly that you're trying to do? Are you creating a > DSL, or something? Basically, albiet a lower-level sort of one. It all goes back to Facet's Annotations lib. Annotations work like this: class X ann :x, :class => String, :default => 10, :foo => :bar end X.ann.x.class #=> String X.ann.x.default #=> 10 X.ann.x.foo #=> :bar X.ann.x.foo = :baz X.ann.x.foo #=> :baz X.ann.x => # String, :default => 10, :foo => :baz}> Annotation class is a subclass of OpenObject, which is much like OpenStruct, but it dynamically prevents method visibility --hence my previous post on #private_filter. And I need that to ensure no new methods pop up that would interfere with OpenObject's functionality. For example: o = OpenObject.new o.yep = 10 o.yep #=> 10 and then, someone else comes along: class Object def yep ; "your sunk" ; end end My method_missing in OpenObject wouldn't catch #yep anymore and she'd be sunk. > method_missing can certainly have it's problems and it needs to be > used with care, but I'm certainly glad it's there. No doubt. No suggestion here of getting rid, or anything of the sort. Just looking for a sounder means for the above type of usecase. T.