On 10/17/06, J2M [email protected] wrote:
I would appreciate any opinions people have on the example so far and
what I may need to include.
I checked out the article and I have a couple of suggestions to make
syntax less repetitive.
- Instead of “has_one” being repeated over and over, why not provide a
block & use method_missing (or ara’s excellect attributes library, just
released) to define all the “has_one” attributes at once:
type :required => true, :length => 10, :select_from => type_options
item, :type => :pseudoformat
Single items are a problem above if you are using method_missing,
Ruby can’t ttell if they refere to a method or local variable. That is,
wouldn’t work quite right:
In that case, maybe provide an array of words instead:
has_one %w(version summary)
- The ratings options is pretty ugly. All that repetition. How about
rating_options 1 … 5, :worst => 1, :best => 5
Also notice the removal of the “=”. Getters can be setters pretty easily
(see again, the attributes gem) and it keeps the syntax simple.
Hope that helps!