couchrest_model/lib/couchrest/model/casted_hash.rb

21 lines
367 B
Ruby

#
# Wrapper around Hash so that the casted_by attribute is set.
module CouchRest::Model
class CastedHash < Hash
include CouchRest::Model::Dirty
attr_accessor :casted_by
def []= index, obj
couchrest_parent_will_change! if obj != self[index]
super(index, obj)
end
# needed for dirty
def attributes
self
end
end
end