Skip to content
This repository
Browse code

change return-guard into if-else

  • Loading branch information...
commit 9b5e972553ca49fc934fd12451a187798e9f2bbf 1 parent 3b891cf
Håkon Lerring authored March 16, 2012 gabebw committed March 16, 2012
39  lib/shoulda/matchers/active_record/serialize_matcher.rb
@@ -65,34 +65,33 @@ def serialization_valid?
65 65
         end
66 66
 
67 67
         def class_valid?
68  
-          if(!@type)
69  
-            return true
70  
-          end
71  
-          
72  
-          klass = model_class.serialized_attributes[@name]
73  
-          
74  
-          if klass == @type
75  
-            true
76  
-          else
77  
-            if klass.respond_to?(:object_class) && klass.object_class == @type
  68
+          if @type
  69
+            klass = model_class.serialized_attributes[@name]
  70
+            if klass == @type
78 71
               true
79 72
             else
80  
-              @missing = ":#{@name} should be a type of #{@type}"
81  
-              false
  73
+              if klass.respond_to?(:object_class) && klass.object_class == @type
  74
+                true
  75
+              else
  76
+                @missing = ":#{@name} should be a type of #{@type}"
  77
+                false
  78
+              end
82 79
             end
  80
+          else
  81
+            true
83 82
           end
84 83
         end
85 84
 
86 85
         def instance_class_valid?
87  
-          if !@instance_type
88  
-            return true
89  
-          end
90  
-          
91  
-          if model_class.serialized_attributes[@name].class == @instance_type
92  
-            true
  86
+          if @instance_type
  87
+            if model_class.serialized_attributes[@name].class == @instance_type
  88
+              true
  89
+            else
  90
+              @missing = ":#{@name} should be an instance of #{@type}"
  91
+              false
  92
+            end
93 93
           else
94  
-            @missing = ":#{@name} should be an instance of #{@type}"
95  
-            false
  94
+            true
96 95
           end
97 96
         end
98 97
 

0 notes on commit 9b5e972

Please sign in to comment.
Something went wrong with that request. Please try again.