
Adding a ".dirty" method to a resource
Reported by Javier | June 18th, 2011 @ 06:00 AM
Just a suggestion for checking dirty attributes on a resource.
For example:
class MyClass
include DataMapper::Resource
property :id, Serial
property :number, Integer
before :save, :check_number
def check_number
if self.dirty.number < self.number
false
else
true
end
end
end
In that example, MyClass instances have a myclass.dirty method that returns dirty version of the object, making it straightforward to check them.
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »