Skip to content

Instantly share code, notes, and snippets.

@buhrmi
Created January 3, 2011 11:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buhrmi/763374 to your computer and use it in GitHub Desktop.
Save buhrmi/763374 to your computer and use it in GitHub Desktop.
A hacky DataMapper monkey patch to mark properties as dirty even if they have not changed
module DataMapper
module Resource
def taint! property
self.persisted_state = State::Dirty.new(self) unless self.persisted_state.kind_of?(State::Dirty)
self.persisted_state.original_attributes[properties[property]] = Object.new
end
end
end
# Example:
# my_resource.array_prop << 123
# my_resource.taint! :array_prop
# my_resource.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment