Permalink
Browse files

Fix style

  • Loading branch information...
1 parent 8785fbe commit fcbf0c579cc13b022006f4ed3efd931dba7c7275 @solnic solnic committed Dec 11, 2011
@@ -844,8 +844,8 @@ def update!(attributes)
if dirty_attributes.empty?
true
- else
- dirty_attributes.each do |property, value|
+ else
+ dirty_attributes.each do |property, value|
property.assert_valid_value(value)
end
unless _update(dirty_attributes)
@@ -1,12 +1,13 @@
module DataMapper
class Property
- # Exception raised when DataMapper is about to work with
+ # Exception raised when DataMapper is about to work with
# invalid property values.
class InvalidValueError < StandardError
attr_reader :property, :value
- def initialize(property,value)
+
+ def initialize(property, value)
msg = "Invalid value %s for property %s (%s) on model %s" %
- [ value.inspect,
+ [ value.inspect,
property.name.inspect,
property.class.name,
property.model.name
@@ -15,6 +16,7 @@ def initialize(property,value)
@property = property
@value = value
end
- end
- end
-end
+
+ end # class InvalidValueError
+ end # class Property
+end # module DataMapper
@@ -68,7 +68,7 @@ def set_repository
def assert_valid_attributes
properties.each do |property|
value = get(property)
- unless property.serial? && value.nil?
+ unless property.serial? && value.nil?
property.assert_valid_value(value)
end
end
@@ -147,7 +147,7 @@ class Article
describe 'when provide an invalid value' do
let(:value) { @invalid_value }
-
+
it_should_behave_like 'assert_valid_value on invalid value'
end
@@ -169,7 +169,7 @@ class ::Default
# FIXME: We cannot trigger a failing save with invalid properties anymore.
# Invalid properties will result in their own exception.
# So Im mocking here, but a better approach is needed.
-
+
describe 'and it is an invalid resource' do
before do
@user.should_receive(:save_self).and_return(false)

0 comments on commit fcbf0c5

Please sign in to comment.