Allow inline blocks to extend concrete classes #21
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.
Implements #19
With this change, users are able to reuse concrete classes as sections while also customizing their behavior inline, enabling advanced inheritance-like behaviors. Example:
Implementation details
Given we don't want the original concrete class to be redefined, we subclass it before evaluating the inline block on its subclass. This was quite a fit given the DSL was already subclassing
Section
.However, getting this to work properly required class instance variables that support the DSL configuration to be inherited by subclasses.
After experimenting with a variety of approaches, I decided to pull active support's class_attribute extension. It's a shame that this brings in a bunch of other dependencies, but for now this seemed like the best solution. We can revisit this later (maybe even copying over class_attribute's implementation given it's MIT-licensed).
I also had to figure out with the confusion around test_ids when using a concrete class (this was already a known logged issue). I decided the concrete class test id will never be used, unless when the class is being explicitly .loaded. This decision felt simply natural when using the framework. It feels consistent and foster code reuse.