-
Type:
Improvement
-
Resolution: Won't Do
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
Currently, Mongoid::Criteria#map ignores its field args if a block is given:
# current Mongoid 7 behavior Dinosaur.all.map(:ignored1, :ignored2) { |dino| "A scary #{dino.color} #{dino.name}!" } #=> [ "A scary green Velociraptor!", "A scary brown T-Rex!" ]
I think this is counter-intuitive. Users would expect these args to be honored and passed into the block:
# proposed behavior Dinosaur.all.map(:name, :color) { |result| "A scary #{result[1]} #{result[0]}!" } #=> [ "A scary green Velociraptor!", "A scary brown T-Rex!" ]
Using a block without field args would still work the old way:
# this behavior will remain as-is Dinosaur.all.map { |dino| "A scary #{dino.color} #{dino.name}!" } #=> [ "A scary green Velociraptor!", "A scary brown T-Rex!" ]
This can be supported done easily with the #pluck_each refactor in PR https://github.com/mongodb/mongoid/pull/5332.
- related to
-
MONGOID-5426 Remove pluck behavior from map
-
- Closed
-