Convert View generator to use RubyClassFile #284
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the course of this, I realized the
RubyFileWriter
(with#call
) is the wrong abstraction. It would create the file, but we couldn't find out any info about that class. In the case of view generation, the template shows the name of the view class, so it needs to be able to see that. In general, being able to get info from a newly generated class file seems useful in other contexts as well (imagine creating an action + operation, the action needs to know what the operation is called).We already had an internal
ClassFile
helper insideRubyFileWriter
, so I extracted that to its ownRubyClassFile
class, which we use in this PR. I added a#fully_qualified_name
method too.If we're happy with this change to the abstraction (
RubyFileWriter
->RubyClassFile
), I can backport the change to the other ones we've already switched. It's just a minor change and I think it's a better API (to call#create
instead of#call
). Since this class has always been private API (and it's an implementation detail for us, not a part of the core framework), I think it's fine to remove it during a patch release, but I'm also fine leaving it around if we're worried about backwards compatibility