B
benny
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,
rop_b1,
rop_b2,
rop_b2=)
end
class B < DelegateClass(A)
attr_accessor
rop_b1,
rop_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)
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
end
class B < DelegateClass(A)
attr_accessor
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)