I have a Rails4 application to which I want to add a model named 'Parameters' It's a good choice in terms of the models purpose, but I worry that it is also a common programming term.
What is the best practice (individual steps) to ensure that:
Ruby has a concept of open classes. That said, when the class
MyClass is defined somewhere, it’s perfectly valid to have the following in your code:
class MyClass def another_method # do something useful end end
That said, there is no “reflection-like” mechanism for this action, since it is how Ruby is intended to work.
One might build the complicated logic like this:
$defined = const_get('Parameters') || true rescue false;
$definedglobal (it’s made global here for the sake of an example) to determine whether the name is free.
Parametersto detect whether only yours was loaded.
ObjectSpace#eachto detect other classes.
But I would not go with any of solutions above. Just call your class
MyAppParameters and live with this name.