1 Sep 2006 01:16
Fwd: [Q] How would you do method extensions (sometimes called class extensions) in Ruby?
Markus Gaelli <gaelli <at> emergent.de>
2006-08-31 23:16:24 GMT
2006-08-31 23:16:24 GMT
Begin forwarded message:
> From: Markus Gaelli <gaelli <at> emergent.de>
> Date: August 31, 2006 11:07:26 PM GMT+02:00
> To: ruby-core <at> ruby-lang.org
> Subject: [Q] How would you do method extensions (sometimes called
> class extensions) in Ruby?
>
> Hi List,
>
> (1) The Problem: Bridge Gap between Tests and Documentation with
> Executable Examples
> May I introduce myself shortly: I am a long-term OOer using mainly
> Smalltalk until now [0] - and I am interested in bridging the gap
> between documentation (static, bound (comments possible for classes
> and methods), often outdated) and unit testing (dynamic, unbound
> [2], up to date) by the metaphor of examples.
>
> (2) The Concept
> I'd like to be able to see exemplified calls for methods ("method
> examples") - and compose new method examples using example
> instances of classes - which in turn are created by "method
> examples" [3]
>
> (3) The Proof of Concept
> I have some prototypes for "Eg" in Smalltalk [3], but wonder how it
> would be possible to do something like this in Ruby.
>
> (4) My Approach in Smalltalk: Relying on Conventions and Method
> Extensions
(Continue reading)
> (I therefore forward another mail which just happened to arrive in
> this moment in my squeak mailbox)
>
> On Aug 31, 2006, at 11:44 PM, Sam Roberts wrote:
>
>> On Fri, Sep 01, 2006 at 06:08:11AM +0900, Markus Gaelli wrote:
>>> I am aware of Singleton Methods, but as they can extend instances,
>>> (how) can I extend classes without changing their original class
>>> definition in Ruby?
>>
>> This is probably best posted to ruby-talk, not ruby-core, folks would
>> likely be quite interested.
>>
>> classes are "open" in ruby, you can add methods as you wish.
>>
>> irb(main):001:0> s = "hi"

RSS Feed