------ art_1929_31062276.1141724577777
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
On 3/7/06, Meinrad Recheis <meinrad.recheis / gmail.com> wrote:
>
> hello fellow rubyists,
>
> is there an elegant way to define a singleton method from a given symbol
> without using eval? what i am doing is this:
>
> def make_wrapper object, method
> eval %{
> def object.#{method}
> # do something here
> super # call the wrapped method
> end
> }
> end
sorry the above code does not work, (needs to be done using
object.instance_eval) but you get the idea what i mean
# example of usage:
> make_wrapper STDOUT, :puts
>
> using eval works, but it seems not to be the best solution. is there
> annother way do define methods from a given symbol?
>
> -- henon
>
>
------ art_1929_31062276.1141724577777--