Originally sent this a couple of days ago, but only sent it to Kevin  
Williams.

Original Message:

==

I still don't like the case statement there...  It won't be able to  
help being magical in it's attempt to not be so magical (though, I  
also fail to see what's magical about a method that takes blocks).  I  
don't like that you have to state twice what sort of format you want  
to deal with if you want to do something other than render a template.

def index
   provides :foo
   case request.format
   when :foo : Object.to_foo
   end
end

seems clumsy beside:

def index
   respond_to do |format|
     format.foo {Object.to_foo}
   end
end

in the case of a rendered template, you do end up with a win though:

class MyController
   provides :html
   def index
     provides :json, :yaml
   end
end

vs.

class MyController
   def index
     respond_to do |format|
       format.html
       format.json
       format.yaml
     end
   end
end

but just as soon as the controller slips past the simple case (which  
I posit it will more often than not, otherwise you'd be using a non- 
content-type-sensitive action), you lose that benefit.

In my mind that API is more of a 20/80 solution for people that  
actually develop RESTful applications on Merb.  I'll illustrate using  
an actual RESTful controller (from a 0.3.7 app) that is in production.

Written using the current style:

http://pastie.caboo.se/107837

Now written using the proposed style:

http://pastie.caboo.se/107838

I just don't see a net benefit in clarity, beauty or brevity.

Sorry to be a curmudgeon.

--

Stephen
(voxdolo)

==

On Oct 16, 2007, at 1:03 PM, Kevin Williams wrote:

> I must be emotionally attached to the current API, because the
> proposal isn't clicking for me. On one hand it makes sense, but on the
> other hand it feels disconnected and doesn't have an obvious flow.
>
> "respond_to" may seem to be a magic box in terms of deciding what
> format to use, but the flow is clear to me.
>
> The "provides" declaration gives a very clear definition of what
> formats to use but appears to have too much magic in *how* the format
> choice is actually made.
>
> Just voicing a concern from a different perspective. Feel free to
> ignore me - still a newbie some days. :)
>
> On 10/16/07, Michael D. Ivey <[EMAIL PROTECTED]> wrote:
>> I'll probably do my respond_to API rewrite, as discussed here:
>>
>>         http://rubyforge.org/pipermail/merb-devel/2007-September/ 
>> 000275.html
>>
>> sometime this week, unless someone has come up with a better API.
>>
>> I'll also work in http://merb.devjavu.com/ticket/227 at the same  
>> time.
>>
>> Any serious objections?
>> _______________________________________________
>> Merb-devel mailing list
>> [email protected]
>> http://rubyforge.org/mailman/listinfo/merb-devel
>>
>
>
> -- 
> Cheers,
>
> Kevin Williams
> http://kevwil.com/
> http://www.almostserio.us/
> http://kevwil.jaiku.com/
> _______________________________________________
> Merb-devel mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/merb-devel

_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to