Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change return-guard into if-else

  • Loading branch information...
commit 9b5e972553ca49fc934fd12451a187798e9f2bbf 1 parent 3b891cf
@Hakon Hakon authored gabebw committed
Showing with 19 additions and 20 deletions.
  1. +19 −20 lib/shoulda/matchers/active_record/serialize_matcher.rb
View
39 lib/shoulda/matchers/active_record/serialize_matcher.rb
@@ -65,34 +65,33 @@ def serialization_valid?
end
def class_valid?
- if(!@type)
- return true
- end
-
- klass = model_class.serialized_attributes[@name]
-
- if klass == @type
- true
- else
- if klass.respond_to?(:object_class) && klass.object_class == @type
+ if @type
+ klass = model_class.serialized_attributes[@name]
+ if klass == @type
true
else
- @missing = ":#{@name} should be a type of #{@type}"
- false
+ if klass.respond_to?(:object_class) && klass.object_class == @type
+ true
+ else
+ @missing = ":#{@name} should be a type of #{@type}"
+ false
+ end
end
+ else
+ true
end
end
def instance_class_valid?
- if !@instance_type
- return true
- end
-
- if model_class.serialized_attributes[@name].class == @instance_type
- true
+ if @instance_type
+ if model_class.serialized_attributes[@name].class == @instance_type
+ true
+ else
+ @missing = ":#{@name} should be an instance of #{@type}"
+ false
+ end
else
- @missing = ":#{@name} should be an instance of #{@type}"
- false
+ true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.