Deprecate `scope_chain` #27851

Merged
merged 5 commits into from Jan 30, 2017

Projects

None yet

5 participants

@tenderlove
Member

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
@eileencodes @tenderlove eileencodes Implement `scopes` method on each Reflection
Each reflection should be responsible for returning the scopes needed to
query against the db.
4fef7c2
@tenderlove tenderlove Fix `scopes` implementation on `PolymorphicReflection`
`PolymorphicReflection` needs to be custom for handling scope lambdas
e8be3a9
@tenderlove tenderlove remove caching until we prove it is required d385162
@tenderlove tenderlove update comments and call `super`
f91bc24
@tenderlove tenderlove deprecate `scope_chain`
233630a
@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
Member

👍

def constraints
- scope_chain.flatten
+ chain.map(&:scopes).flatten
@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