[Groonga-commit] droonga/droonga-engine at 004ffb2 [master] Use guard-style

アーカイブの一覧に戻る

YUKI Hiroshi null+****@clear*****
Thu May 8 16:59:57 JST 2014


YUKI Hiroshi	2014-05-08 16:59:57 +0900 (Thu, 08 May 2014)

  New Revision: 004ffb2ba121b600f45af4f53271d86639acf2d6
  https://github.com/droonga/droonga-engine/commit/004ffb2ba121b600f45af4f53271d86639acf2d6

  Message:
    Use guard-style

  Modified files:
    lib/droonga/serf_event_handler.rb

  Modified: lib/droonga/serf_event_handler.rb (+10 -7)
===================================================================
--- lib/droonga/serf_event_handler.rb    2014-05-08 16:57:31 +0900 (f13db14)
+++ lib/droonga/serf_event_handler.rb    2014-05-08 16:59:57 +0900 (f0ef6ec)
@@ -71,14 +71,17 @@ module Droonga
     end
 
     def last_live_nodes
-      nodes = {}
-      if @live_nodes_file
-        contents = @live_nodes_file.read
-        nodes = JSON.parse(contents) if contents and not contents.empty?
+      return {} unless @live_nodes_file
+      return {} unless @live_nodes_file.exist?
+
+      contents = @live_nodes_file.read
+      return {} if contents.empty?
+
+      begin
+        JSON.parse(contents)
+      rescue JSON::ParserError
+        {}
       end
-      nodes
-    rescue JSON::ParserError
-      {}
     end
 
     def updated_live_nodes
-------------- next part --------------
HTML����������������������������...
ダウンロード 



More information about the Groonga-commit mailing list
アーカイブの一覧に戻る