Reputation: 55
I am working on the model of a Rails app and half of the names I need to use are reserved (and they are also the ones that make more sense within the application. I don't want to find another name). What's the best way to handle this?
I am thinking of using a prefix for all the models (for the ones with reserved words and not) My ideas for "Process":
MyProcess
TheProcess
So whatever prefix I choose, I will use it for every model:
MyUser
TheUser
Thanks!
Upvotes: 1
Views: 110
Reputation: 230521
The standard way to avoid name clashes is namespacing. That is, you put all your "reserved" names (and all of the others, for consistency) in a module. Something like this:
module MyApp
class Signal
# code here
end
end
This way, while within MyApp
, Signal
means your class and ::Signal
will be the one from ruby.
Upvotes: 2