ravendb / ravendb-ruby-client

MIT License
4 stars 5 forks source link

RDBC-139: Use Ruby naming conventions for constants #33

Closed dabroz closed 6 years ago

dabroz commented 6 years ago

In this PR I didn’t change stuff except the naming convention, but generally in Ruby there is no real benefit of using “enum classes” like this:

class AccessMode
    None = "None"
    ReadOnly = "ReadOnly"
    ReadWrite = "ReadWrite"
    Admin = "Admin"
  end

Typically a Ruby library would simply operate on symbols (:read_only etc), and if some conversion is needed to eg. send a query to server, it would be converted to a different value using a dictionary like {read_only: “ReadOnly”, read_write: “UsedToBeReadWriteButNowIsWriteRead”, …}.

Also, and this is more troubling, there are some places that suggest that a constant is used as a variable:

if (DocumentConventions::DefaultUseOptimisticConcurrency &&

or even explicitly suggest that constant should be redefined by user:

  "You can increase the limit by setting RavenDB::DocumentConventions::"\
  "MAX_NUMBER_OF_REQUEST_PER_SESSION

In Ruby such use of constants is incorrect, as they should never be redefined.

dabroz commented 6 years ago

OK, I'll change DocumentConventions not to use constants.

dabroz commented 6 years ago

Changed DocumentConventions to use attributes instead of constants in 0106973.