From: Yehuda Katz Date: 2008-06-24T02:50:01+09:00 Subject: [ruby-core:17385] Re: Any reason for having no module exclusion functionality in Ruby ------=_Part_22467_32868540.1214243502406 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Unfortunately, the solution you provided below introduces a TON of overhead (duping the fairly large controller object, getting the body out of the dup, etc.). It's possible that unextend would be equally slow due to clearing the method cache, but I doubt it'd be as slow as the dup you're proposing. I assume you meant: controller2 = controller.dup controller2.extend Helpers controller2.render controller.body, controller.headers, controller.cookies, ... = controller2.body, controller2.headers, ... In any event, uninclude is a good idea and should be added. The arguments against it at the Implementers meeting had to do with speed, and since when did Ruby ignore powerful features because they were too slow :P -- Yehuda On Mon, Jun 23, 2008 at 9:27 AM, ara.t.howard wrote: > > On Jun 22, 2008, at 9:56 PM, Yehuda Katz wrote: > > n Merb, in particular, it would be nice to be sure that helpers didn't >> override built-in controller methods. At the moment, we do a fairly ugly >> thing of naming internal methods with _method, so that it's less likely for >> the pollution to do anything dangerous, but a much more elegant solution >> would be: include Helpers; result = render; uninclude Helpers; >> finish_dispatch. >> > > controller = controller.dup > controller.extend Helpers > controller.render > > cheap and fixes the issue. > > cheers. > > > a @ http://codeforpeople.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 ------=_Part_22467_32868540.1214243502406 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Unfortunately, the solution you provided below introduces a TON of overhead (duping the fairly large controller object, getting the body out of the dup, etc.).

It's possible that unextend would be equally slow due to clearing the method cache, but I doubt it'd be as slow as the dup you're proposing.

I assume you meant:

controller2 = controller.dup
controller2.extend Helpers
controller2.render
controller.body, controller.headers, controller.cookies, ... = controller2.body, controller2.headers, ...

In any event, uninclude is a good idea and should be added. The arguments against it at the Implementers meeting had to do with speed, and since when did Ruby ignore powerful features because they were too slow :P

-- Yehuda

On Mon, Jun 23, 2008 at 9:27 AM, ara.t.howard <ara.t.howard@gmail.com> wrote:

On Jun 22, 2008, at 9:56 PM, Yehuda Katz wrote:

n Merb, in particular, it would be nice to be sure that helpers didn't override built-in controller methods. At the moment, we do a fairly ugly thing of naming internal methods with _method, so that it's less likely for the pollution to do anything dangerous, but a much more elegant solution would be: include Helpers; result = render; uninclude Helpers; finish_dispatch.

controller = controller.dup
controller.extend Helpers
controller.render

cheap and fixes the issue.

cheers.


a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama







--
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325
------=_Part_22467_32868540.1214243502406--