Created
March 20, 2010 07:53
-
-
Save pathsny/338541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Collection | |
def update!(attributes) | |
... | |
model = self.model | |
dirty_attributes = model.new(attributes).dirty_attributes | |
if dirty_attributes.empty? | |
true | |
elsif dirty_attributes.any? { |property, value| !property.valid?(value) } | |
false | |
else | |
unless _update(dirty_attributes) | |
... | |
end | |
end | |
class Resource | |
def _update | |
original_attributes = self.original_attributes | |
if original_attributes.empty? | |
true | |
elsif original_attributes.any? { |property, _value| !property.valid?(property.get!(self)) } | |
false | |
else | |
... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment