deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@redhat.com
Subject [PATCH 3/9] CIMI: Use class.superclass instead of opts[:class]
Date Fri, 22 Feb 2013 23:52:26 GMT
From: Michal Fojtik <mfojtik@redhat.com>

Under latest MRI 1.9.3 the 'opts[:class]' is not visible
to 'find' method and it is reported as 'method missing'

With 'class.superclass' we get access to the original class
we used to create Ref.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
TrackedAt: http://tracker.deltacloud.org/patch/a24aefe5f66b14b2be6fbc91c0eb2338c4f59a44
---
 server/lib/cimi/models/schema.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/server/lib/cimi/models/schema.rb b/server/lib/cimi/models/schema.rb
index 215ebfc..3f8eb0f 100644
--- a/server/lib/cimi/models/schema.rb
+++ b/server/lib/cimi/models/schema.rb
@@ -189,7 +189,7 @@ class CIMI::Model::Schema
       if CIMI::Model::const_defined?(refname)
         @klass = CIMI::Model::const_get(refname)
       else
-        @klass = Class.new(opts[:class]) do
+        @klass = Class.new(opts[:class]) do |m|
           scalar :href
 
           def ref_id(ctx)
@@ -199,7 +199,11 @@ class CIMI::Model::Schema
           end
 
           def find(ctx)
-            opts[:class].find(ref_id(ctx), ctx)
+            klass.find(ref_id(ctx), ctx)
+          end
+
+          def klass
+            self.class.superclass
           end
         end
         CIMI::Model::const_set(refname, @klass)
-- 
1.8.1.2


Mime
View raw message