[Groonga-commit] groonga/fluent-plugin-droonga [master] Reduce indent by guard if

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Apr 9 19:08:54 JST 2013


Kouhei Sutou	2013-04-09 19:08:54 +0900 (Tue, 09 Apr 2013)

  New Revision: 68a738b69ddd64f680f2fe22b9473098fb3b27ab
  https://github.com/groonga/fluent-plugin-droonga/commit/68a738b69ddd64f680f2fe22b9473098fb3b27ab

  Message:
    Reduce indent by guard if

  Modified files:
    lib/droonga/plugin/handler_search.rb

  Modified: lib/droonga/plugin/handler_search.rb (+18 -17)
===================================================================
--- lib/droonga/plugin/handler_search.rb    2013-04-09 19:07:49 +0900 (ab3a1e5)
+++ lib/droonga/plugin/handler_search.rb    2013-04-09 19:08:54 +0900 (9e11f21)
@@ -220,26 +220,27 @@ module Droonga
       end
 
       def format_records(params, formatted_result)
-        offset = params["offset"] || 0
-        limit = params["limit"] || 10
         attributes = params["attributes"]
-        if attributes.is_a?(Array)
-          target_attributes = attributes.map do |attribute|
-            if attribute.is_a?(String)
-              { label: attribute, source: attribute}
-            else
-              { label: attribute["label"] || attribute["source"],
-                source: attribute["source"] }
-            end
+        return if attributes.nil?
+
+        target_attributes = attributes.map do |attribute|
+          if attribute.is_a?(String)
+            { label: attribute, source: attribute}
+          else
+            { label: attribute["label"] || attribute["source"],
+              source: attribute["source"] }
           end
-          @result.open_cursor(:offset => offset, :limit => limit) do |cursor|
-            formatted_result["records"] = cursor.collect do |record|
-              values = {}
-              target_attributes.collect do |attribute|
-                values[attribute[:label]] = record[attribute[:source]]
-              end
-              values
+        end
+
+        offset = params["offset"] || 0
+        limit = params["limit"] || 10
+        @result.open_cursor(:offset => offset, :limit => limit) do |cursor|
+          formatted_result["records"] = cursor.collect do |record|
+            values = {}
+            target_attributes.collect do |attribute|
+              values[attribute[:label]] = record[attribute[:source]]
             end
+            values
           end
         end
       end
-------------- next part --------------
HTML����������������������������...
Download 



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