Is there something wrong with subclasses of Resource having to do
def initialize(request, response)
super # or super(request, response) if changing signature
Subclasses of Resource do not have to call super. The Webmachine::Resource does not define an initialize method. You can just use it like this.
class Res < Webmachine::Resource
# do stuff here
Not sure if this answers your question. :)
If changing the signature I prefer not having to deal with handling the response & request arguments.
@robgleeson That is exactly why Webmachine does not do as @nyarly suggests. I expect it would be error-prone to require the user to know that the request and response objects would be passed to the initializer. Besides, how often do you actually use the initialize method in a Rails controller? Generally you don't, you use the actions or before/around filters.
I got what was going on in the Resource::new method, I'm just not convinced it's as good an idea as all that.
You're comparing Webmachine to Rails? 😦 Granted, I can't put my finger on my misgivings, apart from a general precept of meta-programming as little as possible. I think part of this is that it's the first step of making request/response "magic" things, as opposed to completely normal ivars.
I'll definitely call into question the idea that it might be confusing to have a programmer not understand basic behaviors of the language, e.g. class inheritance. "Because Rails..." makes me very sad.
Just using the Rails controller as an example, there are other relevant ones.
Sure, it is a fine line to walk. As it is, Webmachine tends to be more on the "less magic" side, but this feels very minor to me.
I agree that resource initialization is unconventional, but I don't believe the current behavior is worth changing.