[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Q: Delegate and Forwardable

benny

3/9/2005 10:43:00 PM

hi,

I am playing around with Delegate and Forwardable,

In the code below, I thought in the run method of class A it should be
possible to set prob_b2 by simply calling

prop_b2 = "something"

as you can see the delegation 'back' works if I want to get the content of
prop_b1.

BTW the same thing when defining an explicit setter method for prob_b2.

any pointers?

benny

##### the code

require 'delegate'
require 'forwardable'

class A
extend Forwardable
def run()
puts "here runs A, giving you property b1: '#{prop_b1}'"
prop_b2 = "new value of b2"
puts @b.prop_b2
@b.prop_b2 = "2nd try: new value of b2"
puts @b.prop_b2
end

def initialize(b)
@b = b
end

def_delegators(:@b, :prop_b1, :prop_b2, :prop_b2=)
end

class B < DelegateClass(A)
attr_accessor :prop_b1, :prop_b2

def initialize(prop_b1)
@prop_b1 = prop_b1
super( A.new(self) )
end
end

b = B.new( "my property b1 content")
b.run

##### output
here runs A, giving you property b1: 'my property b1 content'
nil
2nd try: new value of b2

--
---------------------------------------------------------------------------------------------------
Don't crash when a filter changes the subject of a message which results
in the attempt to remove it from the tree of subject threading messages
failing and the detached child looking for a new parent finding the old
parent as the new parent, which in turn results in the child being deleted
with the old (and new) parent, which is not a good idea, since it is
still referenced.

(Till Adams commit on kdepim/kmail/kmheaders.cpp in HEAD, 6. Jan. 2005)
1 Answer

rL

3/6/2012 6:26:00 PM

0

In article <bhgcl7d7ronjialoj2go3kae451c7qh81u@4ax.com>, duke
<duckgumbo32@cox.net> wrote:

>On Mon, 05 Mar 2012 08:30:12 -0800, rL@somis.org (? R. L. Measures.) wrote:
>
>>In article <pje9l7hmffrrhlq5n92s1jsh4ii9nha2b3@4ax.com>, duke
>><duckgumbo32@cox.net> wrote:
>>
>>>On Mon, 05 Mar 2012 03:17:29 -0800, rL@somis.org (? R. L. Measures.) wrote:
>>>
>>>>In article <rr47l75ve57u6dgqekh4mro55d2sqfo1d2@4ax.com>, duke
>>>><duckgumbo32@cox.net> wrote:
>>>>
>>>>>On Sat, 03 Mar 2012 08:33:50 -0800, rL@somis.org (? R. L. Measures.) wrote:
>>>>>
>>>>>>In article <aa74l717fq69e6vun32ln973hrav4d2rq2@4ax.com>, duke
>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>
>>>>>>>On Sat, 03 Mar 2012 01:06:37 -0800, rL@somis.org (? R. L.
Measures.) wrote:
>>>>>>>
>>>>>>>>In article <e2e1l79jla8hkr8ltam9s6kls9ldjl1kdh@4ax.com>, duke
>>>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>>>
>>>>>>>>>On Thu, 01 Mar 2012 18:03:37 -0800, rL@somis.org (? R. L.
>>Measures.) wrote:
>>>>>>>>>
>>>>>>>>>>In article <m510l7ppgljab1jrk48lpl9mv523eqbjiv@4ax.com>, duke
>>>>>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>>>>>
>>>>>>>>>>>On Wed, 29 Feb 2012 06:31:10 -0800, rL@somis.org (? R. L.
>>>>Measures.) wrote:
>>>>>>>>>>>
>>>>>>>>>>>>In article <766qk792srh4gek19ak4oj2h4d64jn1int@4ax.com>, duke
>>>>>>>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>>On Tue, 28 Feb 2012 06:47:09 -0800, rL@somis.org (? R. L.
>>>>>>Measures.) wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>>In article <tmlpk7pcn89jprgcnuhi88gn98t3sggobb@4ax.com>, duke
>>>>>>>>>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>On Mon, 27 Feb 2012 05:12:54 -0800, rL@somis.org (? R. L.
>>>>>>>>Measures.) wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>In article <m3ckk752l0k036nl9gilel12t50cs8k3fm@4ax.com>, duke
>>>>>>>>>>>>>>>><duckgumbo32@cox.net> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>On Sun, 26 Feb 2012 03:14:54 -0800, rL@somis.org (? R. L.
>>>>>>>>>>Measures.) wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>? How moral is a code that allows the tweaking of
>>>>>>>>>>little girls'
>>>>>>>>>>>>>>>>>>>>nipples.
>>>>>>>>>>>>>>>>>**********
>>>>>>>>>>>>>>>>>>>>>>>>>>>Remember, I'm the one that called it a double
standard.
>>>>>>>>>>>>>>>>>>>>>>>>>>? I also remember who said it was okay.
>>>>>>>>>>>>>>>>>**********
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>It's definitely wasn't me. Who was it?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>? the quote was pretty definite.
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>Yes, it was, and it wasn't me. So who was it?
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>? _______
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>Ah, now you admit the error of your statement.
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>? I think you probably made the statement about nipple
>>>>tweaking.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>**********
>>>>>>>>>>>>>>>>>>>The issue is "who said it was ok?"
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>? It was not a matter of ok, it was a matter of a loving
>>traditon
>>>>>>>>>>inside
>>>>>>>>>>>>>>>>>>one family.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>YOU.........said you remember who said it was ok above. Is
>>>>this just
>>>>>>>>>>>>another
>>>>>>>>>>>>>>>>>case of your machoness when you really don't know?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>Heeheehee.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>? Your ire was the tipping point. .
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>Waiting on you to reveal who said it was ok.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>? is the quote accurate?
>>>>>>>>>>>>>
>>>>>>>>>>>>>No indication that anybody said it was ok.
>>>>>>>>>>>>>
>>>>>>>>>>>>? dodgeball.
>>>>>>>>>>>
>>>>>>>>>>>Well, who?
>>>>>>>>>>>
>>>>>>>>>>? The man in the mirror according to Alan F.
>>>>>>>>>
>>>>>>>>>Stinky's due back in the Broadmoor psycho hospital soon. It's just
>>outside
>>>>>>>>>London.
>>>>>>>>>
>>>>>>>>? Congrats on the bull's-eye Alan.
>>>>>>>
>>>>>>>Haahaahaa.
>>>>>>>
>>>>>>? confirmed.
>>>>>
>>>>>They have a record of an Alan Ferris.
>>>>>
>>>>? who's "they"?
>>>
>>>Broadmoor psycho hospital.
>>>
>>? So you have access to the patient files at Broadmore?
>
>Google found a record.
>
? Patient files posted on the Internet? What's wrong with this picture?

--
Richard L. Measures. AG6K, 805-386-3734, www.somis.org