mongoid / origin

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

A problem with in-place array evolving #60

Closed Exoth closed 11 years ago

Exoth commented 11 years ago

https://github.com/mongoid/origin/blob/master/lib/origin/extensions/object.rb#L189

This line makes in-place evolve. This means, that I get this:

>> a=[1,2,3]
[1, 2, 3]
>> String.evolve(a)
["1", "2", "3"]
>> a
["1", "2", "3"]

This behaviour is quite annoying when used in Mongoid, as, for example, method 'in' uses this transformation.

array = [1, 2, 3]    
SomeModel.in(foo: array)