This message was imported from the Ruby/Rails Modularity Slack server. Find more info in the import thread.
Message originally sent by slack user U71S0G4TZY5
It appears that a pack cannot define a base class in its public directory intended to be extended by other packs. When trying to do this, one sees errors, e.g. RuboCop: Public API method must be a class method (e.g. self.initialize(…)) [Packs/ClassMethodsAsPublicApis] . Can someone explain why this choice was made?
<@U71S0G4TZY5> this cop was an experimental one intended to push folks at Gusto to use class methods for their APIs. At this point, I don’t think it’s a super valuable cop so I’d definitely say turn it off if it’s not serving you (it should be default off).
base class in its public directory intended to be extended by other [packages]
Just for context - I think it’s great to have things like ApplicationRecord public to be inherited from.
As for extension - it’s easy to underestimate the blast radius of changing the behavior of an upstream dependency, similar to the problems you can run into with monkeypatches on library code.
One aspect of this cop that we should probably communicate better: it is definitely not meant for all packs. Since you say “intended to be extended by other packs”, I imagine that you might think of your pack as a library. This cop makes no sense for libraries. In fact, I think it only makes sense of you imagine your pack wanting to become a separate runnable (a separate app). Only in that situation, if you squint, the cop starts enforcing something like a REST API to the pack…