Casted array should notify changes on deletion

Otherwise there is no direct way to delete particular elements.

Workaround with assigning to another array without those elements
is pretty ugly.

* Should notify on deletion at a particular index (Array#delete_at)
* Should notify on deletion of a particular element (Array#delete)

Signed-off-by: Marcos Tapajós <tapajos@gmail.com>
This commit is contained in:
Kostiantyn Kahanskyi 2011-06-06 11:55:15 +02:00 committed by Marcos Tapajós
parent f244b51fbf
commit 0bb00860d1
2 changed files with 54 additions and 0 deletions

View file

@ -50,6 +50,16 @@ module CouchRest::Model
super
end
def delete(obj)
couchrest_parent_will_change! if use_dirty? && self.length > 0
super(obj)
end
def delete_at(index)
couchrest_parent_will_change! if use_dirty? && self.length > 0
super(index)
end
def build(*args)
obj = casted_by_property.build(*args)
self.push(obj)