Getting rid of the route maker
Magnus Holm
judofyr at gmail.com
Sun Jun 22 18:16:35 EDT 2008
The route maker's job is basically two things:
- Make sure that all controllers includes the right mixins
- If any controllers doesn't respond to "urls" (aka. haven't been inherited
from R) define "urls" as ClassName.downcase
The first point can be accomplished within R, but not the latter. But it
should be noted that the latter also can cause some troubles. It's assuming
all constants under Controllers are class and all should be publicly
accessible:
module Camping::Controllers
LIMIT = 6
# Ops! Crashing time!
class HiddenStuff;end
# Ops! Hacking time!
end
By removing the route maker you must explicitly define controllers by
inherited it from R:
module Camping::Controllers
class Posts
end
# No longer working!
# Stick with this:
class Posts < R '/posts'
end
end
What do you think? (It's also 135 bytes smaller). Code available here:
http://github.com/judofyr/camping/tree/no_route_maker
--
Magnus Holm
More information about the Camping-list
mailing list