dmendel / bindata

BinData - Reading and Writing Binary Data in Ruby
BSD 2-Clause "Simplified" License
577 stars 55 forks source link

Rename :onlyif to :if #105

Closed Tails closed 6 years ago

Tails commented 6 years ago

There is probably a reason :onlyif was chosen instead of just :if. Is this because of some conflict that would otherwise exist?

If that's not the case, it would be nice if instead of :onlyif, or in addition to, it would be possible to use :if and :unless. This way, it's more consistent with ActiveRecord: http://guides.rubyonrails.org/active_record_validations.html#using-a-symbol-with-if-and-unless

When I got started using the library it took me a while to realize half my code was trying to use :if instead of :onlyif, though the documentation is clear! :)

dmendel commented 6 years ago

BinData has been around for 11 years and is currently in maintenance. Yes, there are minor naming issues (String's :length is another).

Changing these names would provide a minor increase in readability.

However, this is not worth the cost of forcing people to change existing codebases for a minor cosmetic improvement.

Supporting both :onlyif and :if is a poor solution as codebases mixing the two will have worse readability than before.

The more pragmatic solution is to leave the names as they are.

Tails commented 6 years ago

Thank you for the rationale!