incubator-deltacloud-commits mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1027894&view=rev
Log:
Fixed class spawning to be compatible with Rails

Modified:
    incubator/deltacloud/trunk/client/lib/base_object.rb
    incubator/deltacloud/trunk/client/lib/deltacloud.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=1027894&r1=1027893&r2=1027894&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/base_object.rb (original)
+++ incubator/deltacloud/trunk/client/lib/base_object.rb Wed Oct 27 10:27:04 2010
@@ -16,7 +16,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-require 'lib/string'
+require 'string'
 
 module DeltaCloud
 
@@ -256,18 +256,16 @@ module DeltaCloud
 
     def self.add_class(name, parent=:base)
       parent_class = case parent
-        when :base then BaseObject
-        when :action then ActionObject
-        when :state then StateFullObject
-      end
-      begin
-        return API.const_get(name.classify)
-      rescue NameError
-        API.module_eval("class #{name.classify} < #{parent_class.to_s}; end")
-        new_class = API.const_get(name.classify)
-        @defined_classes ||= []
-        @defined_classes << new_class
-        new_class
+        when :base then 'BaseObject'
+        when :action then 'ActionObject'
+        when :state then 'StateFullObject'
+      end
+      @defined_classes ||= []
+      if @defined_classes.include?(name)
+        DeltaCloud::API.class_eval("#{name.classify}")
+      else
+        DeltaCloud::API.class_eval("class #{name.classify} < DeltaCloud::#{parent_class};
end")
+        DeltaCloud::API.const_get("#{name.classify}")
       end
     end
 

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1027894&r1=1027893&r2=1027894&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Wed Oct 27 10:27:04 2010
@@ -20,10 +20,11 @@ require 'nokogiri'
 require 'rest_client'
 require 'base64'
 require 'logger'
-require 'lib/hwp_properties'
-require 'lib/instance_state'
-require 'lib/documentation'
-require 'lib/base_object'
+
+require 'hwp_properties'
+require 'instance_state'
+require 'documentation'
+require 'base_object'
 
 module DeltaCloud
 



Mime
View raw message