Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Portal API #22

Merged
merged 8 commits into from
Jan 22, 2025
Merged

Implement Portal API #22

merged 8 commits into from
Jan 22, 2025

Conversation

khamusa
Copy link
Contributor

@khamusa khamusa commented Jan 10, 2025

Implement Portals API. This is a new implementation, that replaces my first attempt at it, because it was way too confusing. I basically realized Section and Portals weren't different at all, and the creation of further subclasses was completely unnecessary.

This implementation is being used in this PR in the anywhere repo (Ci fails because it has not configured to download the gem from the private repo, though - does not matter as we're not merging that one right now)

I also realized that implementing the inline blocks extension feature would prepare the terrain for the portals api, so this PR is a child of this one.

Delivers #2

Check the changes to the README.md file for a full description of the API.

@khamusa khamusa force-pushed the feature/2-portal-api-v2 branch from 6b8b4be to 35a31eb Compare January 10, 2025 20:10
@khamusa khamusa changed the title Feature/2 portal api v2 Implement Portal API Jan 10, 2025
@khamusa khamusa force-pushed the feature/2-portal-api-v2 branch 2 times, most recently from 4d78e94 to 3d80462 Compare January 10, 2025 20:34
Given we don't want the original concrete class to be redefined, we subclass
it before evaluating the inline block on its subclass.

However, getting this to work was trickier than I anticipated, because
the class instance variables we were using on the section DSL configuration
would not 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.

I also had to deal with the confusion around test_ids when using
a concrete class. I decided the concrete class test id will never
be used, unless when the class is being explicitly .loaded.
(ref: #17).

This feels more consistent, and foster code reuse.
@khamusa khamusa force-pushed the feature/19-inline-extension-of-concrete-classes branch from bd6a232 to 4850d43 Compare January 14, 2025 19:48
@khamusa khamusa force-pushed the feature/2-portal-api-v2 branch from 3d80462 to c34cda3 Compare January 14, 2025 19:48
@khamusa khamusa marked this pull request as ready for review January 14, 2025 20:20
Copy link
Contributor

@silvabox silvabox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khamusa I'm just making some arbitrary comments as I parse through this - I'm still getting to grips with the structure and intent of it, so please take everything with a pinch of salt 😅

lib/tabasco/configuration.rb Outdated Show resolved Hide resolved
lib/tabasco/configuration.rb Outdated Show resolved Hide resolved
lib/tabasco/configuration.rb Outdated Show resolved Hide resolved
lib/tabasco/section.rb Show resolved Hide resolved
lib/tabasco/section.rb Show resolved Hide resolved
khamusa and others added 7 commits January 21, 2025 17:48
- To foster code reuse, portals can have a global concrete class configured.
- They can also have a concrete class specified when they're declared within a section.
- It is also possible to combine both approaches, but the DSL-declared klass
  is required to be a subclass of the globally configured one.
@khamusa khamusa changed the base branch from feature/19-inline-extension-of-concrete-classes to main January 22, 2025 19:12
@khamusa khamusa merged commit ac6f223 into main Jan 22, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants