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

Deprecate `scope_chain` #27851

Merged
merged 5 commits into from Jan 30, 2017

Conversation

Projects
None yet
5 participants
@tenderlove
Member

tenderlove commented Jan 30, 2017

This PR refactors reflections such that we can iterate over each reflection and ask the reflection object what scopes should be applied to the query we are currently building. This means we don't need to construct a scope_chain array and iterate that array in parallel with the "chain". Instead, we can just ask each item in the chain for the scopes that should be applied, then apply those scopes.

eileencodes and others added some commits Jan 30, 2017

Implement `scopes` method on each Reflection
Each reflection should be responsible for returning the scopes needed to
query against the db.
Fix `scopes` implementation on `PolymorphicReflection`
`PolymorphicReflection` needs to be custom for handling scope lambdas

@tenderlove tenderlove merged commit ef7b9b8 into rails:master Jan 30, 2017

2 checks passed

codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@tenderlove tenderlove deleted the tenderlove:scope-chain branch Jan 30, 2017

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca
Member

rafaelfranca commented Jan 31, 2017

👍

def constraints
scope_chain.flatten
chain.map(&:scopes).flatten

This comment has been minimized.

@WaKeMaTTa

WaKeMaTTa Feb 4, 2017

Is better to use flat_map in stead of map().flatten.

http://apidock.com/ruby/Enumerable/flat_map

@WaKeMaTTa

WaKeMaTTa Feb 4, 2017

Is better to use flat_map in stead of map().flatten.

http://apidock.com/ruby/Enumerable/flat_map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment