I just released a plugin that adds presenters to rails. We have been using it internally, so I would love to get some external feedback. Please let me know what you think:
http://simply_presentable.richcollins.net/
I just released a plugin that adds presenters to rails. We have been using it internally, so I would love to get some external feedback. Please let me know what you think:
http://simply_presentable.richcollins.net/
The example app is asking for a password, perhaps you need to enable public access to:
Crap I thought I did - sorry I'll fix it
Ah the example. I haven't put it up yet so I removed it from the README. Thanks for the catch.
Rich,
Looks like an interesting start, although better usage examples would help.
I hope you don't mind a bit of constructive criticism: I think the use of the bang on present is wrong. (present!) It's an inappropriate use of the idiom, especially considering you have a non-bang version _aliased_ to it.
Maybe it's just me, but when I see a big mistake like that in someone's code it immediately raises red flags about what other problems might be lurking in the codebase. I recommend you drop the bang version of the method.
Cheers, Obie
I used the bang because the present method is doing something somewhat dangerous - adding methods and instance variables to the AR object that might clobber existing methods and attributes.
The bang at the end of a message is often used when the message will modify the receiver instead of returning a new object (sort!). I think it is appropriate to use bang in this case as well since the argument is being modified. I'm not sure that it is a requirement that bang methods always have a safe counterpart.
The alias is just there for backward compatibility. The method originally did not have a bang. The non-bang version of the method is used frequently in the project I extracted the plugin from. I should refactor our code and remove the non-bang methods. I'll remove the alias and commit the change.
I used the bang because the present method is doing something somewhat dangerous - adding methods and instance variables to the AR object that might clobber existing methods and attributes.
Why not return a proxy, instead of modifying the instance? it's way less likely to break anything, and probably faster to boot :).
I use SingleForwardable (http://ruby-doc.org/core/classes/ SingleForwardable.html), a type of proxy that defines methods and sets instance variables (AFAIK).