I just pushed a new feature to Camping: Simple controllers. module App::Controllers get ''/(.*)'' do |name| "Hello #{name}" end end What do you think? Useful? Or should I revert it? It currently costs us 87 bytes. // Magnus Holm
Personally I probably won''t be using it, I like having class names around and being able to link to them with R(). (I change my paths often.) Certainly won''t hurt to have it, for really small apps. -- Matma Rex
Would you have to write the RE for every declaration? ie... module App::Controllers get ''/(.*)'' do |name| "Hello #{name}" end put ''/(.*)'' do |name| "Hello #{name}" end end Dave On Thu, Aug 25, 2011 at 1:20 PM, Magnus Holm <judofyr at gmail.com> wrote:> I just pushed a new feature to Camping: Simple controllers. > > ?module App::Controllers > ? ?get ''/(.*)'' do |name| > ? ? ?"Hello #{name}" > ? ?end > ?end > > What do you think? Useful? Or should I revert it? It currently costs > us 87 bytes. > > // Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Dave
On Thu, Aug 25, 2011 at 21:28, David Susco <dsusco at gmail.com> wrote:> Would you have to write the RE for every declaration? > > ie... > > ?module App::Controllers > ? get ''/(.*)'' do |name| > ? ? "Hello #{name}" > ? end > > ? put ''/(.*)'' do |name| > ? ? "Hello #{name}" > ? end > ?endThat wouldn''t work. Camping would dispatch all methods to the first controller (so you''ll get a 501 error when you PUT). In that case you''ll have to refactor it into a proper controller. Which I consider a good thing (DRY etc.)
If I wanted that notation, I''d just use Sinatra. ;) Like Bartosz, I like having named controllers so that I can pass them to R() when generating links. On Thu, Aug 25, 2011 at 10:20 AM, Magnus Holm <judofyr at gmail.com> wrote:> I just pushed a new feature to Camping: Simple controllers. > > module App::Controllers > get ''/(.*)'' do |name| > "Hello #{name}" > end > end > > What do you think? Useful? Or should I revert it? It currently costs > us 87 bytes. > > // Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20110825/6be78627/attachment.html>
On Aug 25, 2011 10:54 PM, "John Beppu" <john.beppu at gmail.com> wrote:> > If I wanted that notation, I''d just use Sinatra. ;) > > Like Bartosz, I like having named controllers so that I can pass them toR() when generating links. Does it make it better that you can name them too? Index = get "/" do ... end Sent from my iCampingPhone -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20110825/905c593d/attachment.html>
I vote revert. This is just sinatra - I feel it''s important camping maintains the cleanliness and clarity of functionality given to us by using simple classes. It''s something we have which AFAIK no other ruby web framework does - you know exactly how it works, because it''s just a class. On 26/08/2011, at 7:21 AM, Magnus Holm wrote:> On Aug 25, 2011 10:54 PM, "John Beppu" <john.beppu at gmail.com> wrote: > > > > If I wanted that notation, I''d just use Sinatra. ;) > > > > Like Bartosz, I like having named controllers so that I can pass them to R() when generating links. > > Does it make it better that you can name them too? > > Index = get "/" do > ... > end > > Sent from my iCampingPhone > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20110826/e2c7972b/attachment.html>
Being able to name controllers definitely makes it more valuable. If I had to criticize Sinatra and its clones, I would criticize their lack of named controllers. It''s difficult to write URL generation functions without them. I''ve only seen one Sinatra clone (Slim in php) that allows controllers to be named. On Thu, Aug 25, 2011 at 2:21 PM, Magnus Holm <judofyr at gmail.com> wrote:> On Aug 25, 2011 10:54 PM, "John Beppu" <john.beppu at gmail.com> wrote: > > > > If I wanted that notation, I''d just use Sinatra. ;) > > > > Like Bartosz, I like having named controllers so that I can pass them to > R() when generating links. > > Does it make it better that you can name them too? > > Index = get "/" do > ... > end > > Sent from my iCampingPhone > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20110825/bba2d12f/attachment-0001.html>
So, are we reverting it? It''s still in the latest GitHub commit. (If it was unclear, I agree with Jenna - while certainly neat, this should go.) -- Matma Rex