lib/restful_model_collection.rb in inbox-0.16.0 vs lib/restful_model_collection.rb in inbox-0.16.1

- old
+ new

@@ -42,10 +42,19 @@ range(0, Float::INFINITY) end def where(filters) collection = self.clone - collection.filters ||= {} + + # deep copy the object, otherwise filter is shared among all + # the instances of the collection, which leads to confusing behaviour. + # - karim + if collection.filters == nil + collection.filters = {} + else + collection.filters = Marshal.load(Marshal.dump(collection.filters)) + end + collection.filters.merge!(filters) collection end def range(offset = 0, limit = 100)