Reputation: 329
I am wondering if there is any special notation or common practice when it comes to referring (outside of actual code, either in comments, source control commit messages, or documentation) to nested classes in Ruby/Rails. I ask because in the application there is this code:
class Reporting::Search < ActiveRecord::Base
#Reporting module is defined outside this file.
...
class Data < HashWithIndifferentAccess
...
end
...
end
And my commit message reads:
Modifies [...] in the Data class within Reporting::Search, [...]"
Is there a more standard way to phrase this? Something like Reporting::Search::Data
or Reporting::Search.Data
?
Upvotes: 1
Views: 234
Reputation: 62648
Reporting::Search::Data
is correct. Your hierarchy there is analogous to:
module Reporting
class Search < ActiveRecord::Base
class Data <HashWithIndifferentAccess; end
end
end
And in fact, this form is preferred, since it will define the Reporting
module if it is not already defined, while the Reporting::Search
form will throw an exception.
Upvotes: 3