# Before(:each) hard to emulate / capture?

**URL:** <https://www.ruby-forum.com/t/before-each-hard-to-emulate-capture/124718>\
**Category:** Ruby\
**Created:** [January 1, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/before-each-hard-to-emulate-capture/124718 "2008-01-01T18:43:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giles\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@Giles\_B](https://www.ruby-forum.com/u/Giles_B)\
**Post date:** [January 1, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/before-each-hard-to-emulate-capture/124718/1 "2008-01-01T18:43:46Z")

</div>

Is there an easy way for a class to incorporate an existing module but  
also stipulate that it will capture any value returned by the methods  
in that module into one ivar?

–  
Giles B.

Podcast: [http://hollywoodgrit.blogspot.com](http://hollywoodgrit.blogspot.com)  
Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)  
Tumblelog: [http://giles.tumblr.com](http://giles.tumblr.com)

---

<div class="post-metadata">

**Author:** ![Giles\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/848f3c/32.png) [@Giles\_B](https://www.ruby-forum.com/u/Giles_B)\
**Post date:** [January 1, 2008, 10:22pm UTC](https://www.ruby-forum.com/t/before-each-hard-to-emulate-capture/124718/2 "2008-01-01T22:22:49Z")

</div>

On Jan 1, 2008 6:42 PM, Giles B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Tumblelog: [http://giles.tumblr.com](http://giles.tumblr.com)

Sorry Gilles I have no Ruby and an impossible keyboard at hand, but  
the basic idea would be

module M …  
def self.included into\_mod  
methodes.each do ! mn !  
m = method mn  
into\_mod.send( :module\_eval, “def #{mn} \*args, &blk;  
@{mn}=super(\*args,&blk);end” )  
etc.etc.

HTH  
Robert

–

[http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)

* * *

All truth passes through three stages. First, it is ridiculed. Second,  
it is violently opposed. Third, it is accepted as being self-evident.  
Schopenhauer (attr.)
