incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1027895 - /incubator/deltacloud/trunk/client/lib/base_object.rb
Date Wed, 27 Oct 2010 10:27:14 GMT
Author: mfojtik
Date: Wed Oct 27 10:27:14 2010
New Revision: 1027895

URL: http://svn.apache.org/viewvc?rev=1027895&view=rev
Log:
Replaced collect and select with inject

Modified:
    incubator/deltacloud/trunk/client/lib/base_object.rb

Modified: incubator/deltacloud/trunk/client/lib/base_object.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/base_object.rb?rev=1027895&r1=1027894&r2=1027895&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/base_object.rb (original)
+++ incubator/deltacloud/trunk/client/lib/base_object.rb Wed Oct 27 10:27:14 2010
@@ -119,7 +119,7 @@ module DeltaCloud
       private
 
       def search_for_method(name)
-        @objects.select { |o| o[:method_name] == "#{name}" }.first
+        @objects.detect { |o| o[:method_name] == "#{name}" }
       end
 
     end
@@ -153,7 +153,10 @@ module DeltaCloud
       end
 
       def actions
-        @objects.select {|o| o[:type].eql?(:action_link) }.collect { |o| [o[:rel], o[:href]]
}
+        @objects.inject([]) do |result, item|
+          result << [item[:rel], item[:href]] if item[:type].eql?(:action_link)
+          result
+        end
       end
 
       def action_urls



Mime
View raw message