matz
11/18/2003 5:03:00 PM
Hi,
I'd recommend you to check CLOS.
In message "Re: Yet Another Rite Thought: method combination"
on 03/11/18, "Christoph" <chr_mail@gmx.net> writes:
|> Can you give me an example with 2 classes (inheritance + wrappers) ?
|
|class A
| def foo
| p "A"
| end
| def foo:pre
| p "pre_a"
| end
| def foo:post
| p "post_a"
| end
|
| def foo:wrap
| super
| p "A"
| end
|end
|
|class B < A
| def foo
| super
| p "B"
| end
| def foo:pre
> # super # no super in pre method
| p "pre_b"
| end
| def foo:post
> # super # no super in post method
| p "post_b"
| end
|
| def foo:wrap
| super
| p "B"
| end
|end
>B.new.foo
"pre_b"
"pre_a"
"A"
"B"
"post_a"
"post_b"
"A" # from wrap
"B" # from wrap
matz.