[LRUG] Getting rid of 'proc'
Paolo Dona
paolo.dona at seesaw.it
Wed Apr 18 03:24:24 PDT 2007
It seems right... tonight I'll try to apply that pattern to the tabnav and
let you know, the last time I tried it this way it didn't work but maybe I
was doing something wrong...
Thank you guys, I owe you a beer (and that means I gotta attend another
meeting :-))
Paolo
On 4/18/07, Paul Battley <pbattley at gmail.com> wrote:
>
> On 18/04/07, Paolo Dona <paolo.dona at seesaw.it> wrote:
> > Hi Paul, your sample seems good, but what I'm trying to do with tabnav
> is a
> > little bit more complicated.
> >
> > You're able to define the block do p @foo end because @foo is an
> instance
> > variable of your class A (that could correspond to the tabnav model) but
> > inside the tabnav I should reference something that exists only in the
> > views's context, not the model.. imagine to evaluate a @foo that's
> inside
> > another class..
>
> Paolo, does this do what you expect, or am I missing something?
>
> ---
> #!/usr/bin/env ruby
>
> class A
> def define(&blk)
> @fn = blk
> end
>
> def evaluate(context)
> context.instance_eval(&@fn)
> end
> end
>
> class B
> def initialize
> @foo = 42
> end
> end
>
> a = A.new
> a.define do
> p @foo
> end
> b = B.new
> a.evaluate(b) # => 42
>
> ---
>
> Paul.
> _______________________________________________
> chat mailing list
> chat at lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
--
Paolo Dona'
SeeSaw | Another point of view
http://www.seesaw.it
paolo.dona at seesaw.it
personal http://paolodona.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20070418/bca14761/attachment-0003.html>
More information about the Chat
mailing list