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

feat(variant): different transformer variants can be used #32

Merged
merged 3 commits into from
Feb 25, 2019

Conversation

rhwilr
Copy link
Owner

@rhwilr rhwilr commented Feb 22, 2019

This PR will add the option to define multiple transform method in a Transformer class. These other transform methods are referred to as "variants".

  • If no variant is defined, the default "transform" method will be used.
  • A variant must be named as follows: transform{VariantName}
  • A variant can be used by specifying it using the usingVariant method
  • A variant can also be specified using dot-notation when passing the transformer as a string: App/Transformers/IDTransformer.variant1

@codecov
Copy link

codecov bot commented Feb 22, 2019

Codecov Report

Merging #32 into next will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@         Coverage Diff         @@
##           next    #32   +/-   ##
===================================
  Coverage   100%   100%           
===================================
  Files        37     38    +1     
  Lines       951   1020   +69     
===================================
+ Hits        951   1020   +69
Impacted Files Coverage Δ
src/Bumblebee/Scope.js 100% <100%> (ø) ⬆️
src/Bumblebee/index.js 100% <100%> (ø) ⬆️
src/Bumblebee/Resources/ResourceAbstract.js 100% <100%> (ø) ⬆️
test/transformer.spec.js 100% <100%> (ø) ⬆️
test/transformer-variants.spec.js 100% <100%> (ø)
src/Bumblebee/Manager.js 100% <100%> (ø) ⬆️
src/Bumblebee/TransformerAbstract.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16a6142...3cdb1bb. Read the comment docs.

@rhwilr
Copy link
Owner Author

rhwilr commented Feb 22, 2019

@RomainLanz I have a working PoC and would love to get your feedback on it.
I really like the way we can set the variant using the same as with controllers in routes.

Maybe you can take a quick look at the test to see if you like the API transformer-variants.spec.js?

Also, I have been looking through the Adonis source code to see how Adonis does the Controller/Method resolution and how the default namespace gets prepended to controllers. But I could not find it. Maybe you can point me in the right direction?

@RomainLanz
Copy link
Contributor

Nice! I'll give it a shot in this project https://github.com/Lausanne-eSports/api.els.team

@RomainLanz
Copy link
Contributor

I believe you can merge it and release it as a new beta. 👍

@rhwilr
Copy link
Owner Author

rhwilr commented Feb 25, 2019

Will do! Probably tomorrow, maybe even later this evening.
Thanks for checking it out! 😃

@rhwilr rhwilr changed the title WIP: feat(variant): different transformer variants can be used feat(variant): different transformer variants can be used Feb 25, 2019
@rhwilr rhwilr merged commit 8a6ff04 into next Feb 25, 2019
@rhwilr rhwilr deleted the feature/multiple_transform_methods branch February 25, 2019 22:13
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