now using ActiveModel::Dirty. only writes to database if model.changed?
This commit is contained in:
parent
53b052f631
commit
4dbf694e51
14 changed files with 342 additions and 18 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
module CouchRest::Model
|
||||
class CastedArray < Array
|
||||
include CouchRest::Model::Dirty
|
||||
attr_accessor :casted_by
|
||||
attr_accessor :property
|
||||
|
||||
|
@ -14,15 +15,34 @@ module CouchRest::Model
|
|||
end
|
||||
|
||||
def << obj
|
||||
couchrest_parent_will_change!
|
||||
super(instantiate_and_cast(obj))
|
||||
end
|
||||
|
||||
def push(obj)
|
||||
couchrest_parent_will_change!
|
||||
super(instantiate_and_cast(obj))
|
||||
end
|
||||
|
||||
def pop
|
||||
couchrest_parent_will_change!
|
||||
super
|
||||
end
|
||||
|
||||
def shift
|
||||
couchrest_parent_will_change!
|
||||
super
|
||||
end
|
||||
|
||||
def unshift(obj)
|
||||
couchrest_parent_will_change!
|
||||
super(obj)
|
||||
end
|
||||
|
||||
def []= index, obj
|
||||
super(index, instantiate_and_cast(obj))
|
||||
value = instantiate_and_cast(obj)
|
||||
couchrest_parent_will_change! if value != self[index]
|
||||
super(index, value)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue