Proposed API change for respond_to
ry dahl
ry at tinyclouds.org
Thu Sep 20 13:21:46 EDT 2007
Sometimes it seems like actions deserve to be their own objects: we
map routes to them, we'd like to know what parameters they expect, we
want to say which http methods they accept, we assign them
before/after filters, and we even hold collections of them
(Controller.callable_actions). This responds_to issue is another
example of how we'd like to treat actions as objects. We would like
for the controller to look at the request, determine which format to
send, and then simply call my_action.render_json or
my_action.render_html. Simultaneously, our controllers are not very
class like. They are basically instantiate them only to call the
action. Changing the Controller class into a module would not be so
hard in the current Merb - they are (more or less) just containers for
actions.
Has anyone else been having these thoughts?
ry
On 9/20/07, Michael D. Ivey <ivey at gweezlebur.com> wrote:
> On Sep 20, 2007, at 12:54 AM, Josh Susser wrote:
> > I very much dislike the respond_to case-statement style of handling
> > multiple formats. If you have a class that has the same case
> > statement in most of its methods, then it should be broken up into
> > multiple classes. Case statements to select behavior that way are
> > redundant in an object-oriented language.
>
> Do you mean you dislike the current respond_to, my proposed change,
> or both? :)
>
> Any chance you'll have a high-level picture of what you're thinking
> before the weekend? I'd love to see it.
> _______________________________________________
> Merb-devel mailing list
> Merb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/merb-devel
>
More information about the Merb-devel
mailing list