mongoid / origin

A Ruby DSL for building MongoDB queries
http://mongoid.org/en/origin/index.html
MIT License
62 stars 29 forks source link

Selector#merge! with block #97

Open nanocity opened 10 years ago

nanocity commented 10 years ago

Current implementation of Selector#merge! does not support selecting value preference for duplicate keys.

Hash#merge! accomplish this by passing a block which is only called when keys are duplicated and return the desired value.

The thing is, I'm not using Selector#merge! directly but through _ActiveSupport#reversemerge! which is usefull to me to create custom filters but I'm not sure about manipulating selector hash is a good practice.

So, what do you think? It should be fine to support this or should I change my own implementation?

Thanks!