Does anyone else finds attribute query methods semantically confusing?

Hi,

Consider this code:

post = Post.new(:visible => true, :url => "http://com";)

if post.visible?
  puts "ima visible!"
end

if post.url?
  puts "ima url! (wait wat? o_0)"
end

Does this feel right to you? In case with post.url? i read it as "Hey post 
object, are you an url?" which is apparently not what the code will do.

So it seems like semantically perfect flag checks go together with totally 
confusing(for a reader) way of checking whether an attribute is present or 
not.

I would generate attribute query methods only for boolean attributes.

Regards, Max

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-core/-/YqYSFrZrLWIJ.
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.

Reply via email to