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 support for proc resource in one polymorphic associations #281

Conversation

alejandroperea
Copy link
Contributor

This PR adds support for using procs in one associations for selecting the resource serializer.

So, now will be able to use something like this:

  class SoundtrackSerializer
    include Alba::Resource

    one :content, resource: ->(content) { content.is_a?(Movie) ? MovieResource : TvShowResource }
  end

@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #281 (6316509) into main (b7ddbeb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #281   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files          12       12           
  Lines         488      489    +1     
=======================================
+ Hits          484      485    +1     
  Misses          4        4           
Impacted Files Coverage Δ
lib/alba/association.rb 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@okuramasafumi
Copy link
Owner

Thank you!

@okuramasafumi okuramasafumi merged commit 692366a into okuramasafumi:main Dec 2, 2022
@alejandroperea alejandroperea deleted the support-proc-for-one-associations branch December 2, 2022 10:23
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