Support expressions in selectattr/rejectattr#249
Conversation
Codecov Report
@@ Coverage Diff @@
## master #249 +/- ##
============================================
+ Coverage 71.84% 71.87% +0.02%
- Complexity 1402 1405 +3
============================================
Files 220 220
Lines 4412 4420 +8
Branches 700 701 +1
============================================
+ Hits 3170 3177 +7
Misses 1002 1002
- Partials 240 241 +1
Continue to review full report at Codecov.
|
|
Understand the performance issues. Perhaps there's a way to allow some of the functionality without allowing everything. The 4th parameter being permitted filters to apply to the value of the attribute. You could then restrict which filters were applied. |
Previous PR allowed nested properties in
selectattrandrejectattr#238.This is great however is still limiting because you cannot execute filters. For example you may have a list of objects you would like to map to a value before executing the filter:
|selectattr("optionList|map('id')", "containing", 1)or perhaps you would like to trim the values|selectattr("name|trim|lower", "equalto", "matt").This resolves the first argument as an expression and then applies the test case. The solution is hacky as it stores a temporary variable to resolve the expression against. I have not thought of a way to get around this.
Motivation: This makes it easier to filter many HubL/HubSpot objects that have properties that are lists of other objects. Previously this required a for loop.