On 02/10/05, Robert Klemme <bob.news / gmx.net> wrote:
> Brian Schröäer <ruby.brian / gmail.com> wrote:
> > [snip]
>
> Just don't use the block for define_method but invoke it from the closure:
>
> class A
>   def self.def_me(cmd,&block)
>     define_method(cmd) do
>       puts "preparation"
>       instance_eval &block
>     end
>   end
>
>   attr_accessor :name
> end
>
> a=A.new
> a.name = "Einstein"
>
> A.def_me(:foo) do
>   puts @name, self.name
> end
>
> >> a.foo
> preparation
> Einstein
> Einstein
> => nil
>
> Kind regards
>
>     robert
>
>
>

thanks a lot thats perfect. I have to wrap my mind around all the
different evals and definition methods and have them at hand when
needed. Theres a long way to go.

best regards,

Brian

--
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/