deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/3] Core: Fix incompatibility between 1.9 and 1.8 ruby in listing methods
Date Fri, 11 May 2012 10:41:39 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/drivers/base_driver.rb |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index ab8fb1a..a100828 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -104,16 +104,13 @@ module Deltacloud
       hwp = nil
       if name
         unless hwp = hardware_profiles(credentials, :id => name).first
-          raise BackendError.new(400, "bad-hardware-profile-name",
-            "Hardware profile '#{name}' does not exist", nil)
+          raise BackendError.new(StandardError.new, "Hardware profile '#{name}' does not
exist")
         end
       else
-        unless image = image(credentials, :id=>image_id)
-          raise BackendError.new(400, "bad-image-id",
-              "Image with ID '#{image_id}' does not exist", nil)
+        unless image = image(credentials, :id => image_id)
+          raise BackendError.new(StandardError.new, "Image with ID '#{image_id}' does not
exist")
         end
-        hwp = hardware_profiles(credentials,
-                                :architecture=>image.architecture).first
+        hwp = hardware_profiles(credentials, :architecture=>image.architecture).first
       end
       return hwp
     end
@@ -144,7 +141,8 @@ module Deltacloud
     end
 
     def has_capability?(method)
-      (self.class.instance_methods - self.class.superclass.instance_methods).include? method.to_s
+      method = RUBY_VERSION =~ /^1\.9/ ? method : method.to_s
+      (self.class.instance_methods - self.class.superclass.instance_methods).include? method
     end
 
     ## Capabilities
-- 
1.7.10.1


Mime
View raw message