On Thu, May 31, 2012 09:23, Sam Oliver wrote: > On Thu, May 31, 2012 at 2:12 PM, James B. Byrne > <[email protected]>wrote: > >> >> > I would generate attribute query methods only for boolean >> attributes. >> >> I am not sure that I understand your point, but in Ruby anything >> that >> is neither nil nor false is true. Thus returning the url string, if >> not nil, is the same as saying that it is true but also allows >> access >> to the actual data without having to send another message. >> > > I think Max's point is that "post.visible?" could be read as "post is > visible?" but "post is url?" carries a different meaning. >
This really comes down to ones own understanding of English. Since visible is a quality of some object one may reasonably infer that #visible? is synonymous with #is_visible? This might not actually be the case of course but the inference is strong. In the case of #url? an url is not a quality, it is an object in own right even if its representation is wholly contained within the state of a container object (i.e. an attribute with a string value). I agree with the OP that in this case #url? is not good form and that #url is a superior since it imparts the idea that one should receive a representation and not simply a boolean. However, #has_url? or #has_anything? to me would be pointless in Ruby. If an object has one then just tell it to provide it and if nil is returned then it does not. -- *** E-Mail is NOT a SECURE channel *** James B. Byrne mailto:[email protected] Harte & Lyne Limited http://www.harte-lyne.ca 9 Brockley Drive vox: +1 905 561 1241 Hamilton, Ontario fax: +1 905 561 0757 Canada L8E 3C3 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
