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

Add a with keyword #7

Closed
wants to merge 1 commit into from

Conversation

perlancar
Copy link
Contributor

The syntax is compatible with Moose's with.

This commit builds upon PR#6.

Tests can be added upon request.

The syntax is compatible with Moose's with.

This commit builds upon PR#6.
@perlancar
Copy link
Contributor Author

I released a temporary module for this: https://metacpan.org/release/PERLANCAR/MooX-Role-Parameterized-With-Keyword-0.001

@peczenyj
Copy link
Owner

How this PR is related to pull request #6 ?

@perlancar
Copy link
Contributor Author

How this PR is related to pull request #6 ?

I use the same fallback mechanism like in #6. So when the role is not parameterized (determined by whether the user specifies parameters or not, yes this is not ideal but anyways...), then the role can be added either using apply(), or if apply() is not available then using Moo::Role->add_roles_to_package or the Role::Tiny equivalent.

@perlancar
Copy link
Contributor Author

BTW, the specific use case that I'm facing:

I have Role::Versioning::Scheme which is used by the other roles: Versioning::Scheme::Monotonic, Versioning::Scheme::Semantic, Versioning::Scheme::Perl. They are all Role::Tiny roles.

I want to add a new role Versioning::Scheme::CalVer (ref: https://calver.org/) as a separate Perl distribution, where I want to let role users specify the calendar pattern to use, e.g. YY.MM. This determines version normalizing, comparing, bumping. So Versioning::Scheme::CalVer will be a parameterized role. I don't want to have to switch to MooX::Role::Parameterized for the other already-written roles.

@peczenyj
Copy link
Owner

This was reimplemented on v0.100

@peczenyj peczenyj closed this Dec 29, 2023
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.

2 participants