From: Alex Gutteridge Date: 2013-02-16T01:46:09+09:00 Subject: Re: Ruby "visionary" code On 15.02.2013 16:22, Elr0ndK Asda wrote: > The second one has been written only for a conditional validation (in > the same model), example: > > - validate_presence_of :field, :if => :is_not_a_feature? > > But Ruby have also the unless, so it seems to me absolutely unuseful. > > In addition, I'm not expert of Rails and Ruby, but I think also that > the > first method is redundant: > featured is a boolean field of the related database table and in my > thought, adding an attr_reader for the featured field, there are no > needs of other methods. It's quite common in Ruby to alias methods if that improves readability. Whether you consider the additional code worthwhile seems to me a pretty subjective call. Generally I would agree with you though that generating a whole new method just for negation seems a bit OTT. I would also rewrite the first method using alias to make it even more obvious that that is all it is. -- Alex Gutteridge