From: gabriele renzi Date: 2008-02-09T06:05:07+09:00 Subject: Re: Syntax Opinions On Fri, 08 Feb 2008 15:30:52 -0500, Michael Boutros wrote: > 1) Enclose the methods in a block with the same name as the HTTP method. > get do > def post > @post = ... > end > end verbose > 2) My personal favourite which needs no explanation... > def @get.post > @post = ... > end > > What do you guys think? Seems better, but why not def get.post ? @post.. end You just need to provide self.get (and self.post/put/delete) as an accessor on the base class, which is also useful for setting up the value conditionally. But probably you meant this. There is also one more option, which is more hackish (and not thread safe) which would be: class C get def foo.. end def bar.. end post def foo.. end def quux .. end end Which IMO is way better than the rest, easily allows you to avoid specifying anything on the default GET, but suggests grouping of similar HTTP versbs. Dummy implementation: >> class C >> def self.post >> def self.method_added(name) >> POST<< name >> end >> end >> def self.get # meta-meta left as exercise for the reader ;) >> def self.method_added(name) >> GET<< name >> end >> end >> POST=[] >> GET=[] >> end => [] >> class D < C >> get >> def foo() 'foo' end >> def bar() 'bar' end >> post >> def quux() 'quux' end >> def foo() 'foo post' end >> end => nil >> D::POST => [:quux, :foo] >> D::GET => [:foo, :bar]