[Groonga-commit] droonga/droonga-engine at 19268ce [master] Separate long method to short methods

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 23 10:23:09 JST 2015


YUKI Hiroshi	2015-04-23 10:23:09 +0900 (Thu, 23 Apr 2015)

  New Revision: 19268ce7ac96b5cec357e9583ad9f42670f38ef2
  https://github.com/droonga/droonga-engine/commit/19268ce7ac96b5cec357e9583ad9f42670f38ef2

  Message:
    Separate long method to short methods

  Modified files:
    lib/droonga/differ.rb

  Modified: lib/droonga/differ.rb (+22 -14)
===================================================================
--- lib/droonga/differ.rb    2015-04-23 10:17:35 +0900 (ede4b6c)
+++ lib/droonga/differ.rb    2015-04-23 10:23:09 +0900 (6ab44d2)
@@ -19,21 +19,9 @@ module Droonga
       def diff(a, b)
         case a
         when Hash
-          difference = {}
-          (a.keys + b.keys).uniq.each do |key|
-            unless a[key] == b[key]
-              difference[key] = diff(a[key], b[key])
-            end
-          end
-          difference
+          diff_hashes(a, b)
         when Array
-          difference = {}
-          [a.size, b.size].max.times do |index|
-            unless a[index] == b[index]
-              difference[index] = diff(a[index], b[index])
-            end
-          end
-          difference
+          diff_arrays(a, b)
         else
           if a == b
             nil
@@ -42,6 +30,26 @@ module Droonga
           end
         end
       end
+
+      def diff_hashes(a, b)
+        difference = {}
+        (a.keys + b.keys).uniq.each do |key|
+          unless a[key] == b[key]
+            difference[key] = diff(a[key], b[key])
+          end
+        end
+        difference
+      end
+
+      def diff_arrays(a, b)
+        difference = {}
+        [a.size, b.size].max.times do |index|
+          unless a[index] == b[index]
+            difference[index] = diff(a[index], b[index])
+          end
+        end
+        difference
+      end
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index