Sha256: f0b1ed5e710ea5a56b91136033b7d67d0eeb54f50267d7e4c59d897d80b05698

Contents?: true

Size: 754 Bytes

Versions: 45

Compression:

Stored size: 754 Bytes

Contents

module Fog
   # get class by string or nil
   def self.class_from_string classname, defaultpath=""
     if classname and classname.is_a? String then
        chain = classname.split("::")
        klass = Kernel
        chain.each do |klass_string|
           klass = klass.const_get klass_string
        end
        if klass.is_a? Class then
           klass
        elsif defaultpath != nil then
           Fog.class_from_string((defaultpath.split("::")+chain).join("::"), nil)
        else
           nil
        end
     elsif classname and classname.is_a? Class then
        classname
     else
        nil
     end
   rescue NameError
     defaultpath != nil ? Fog.class_from_string((defaultpath.split("::")+chain).join("::"), nil) : nil
   end
end

Version data entries

45 entries across 45 versions & 4 rubygems

Version Path
fog-core-1.21.1 lib/fog/core/class_from_string.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/core/class_from_string.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/core/class_from_string.rb
fog-core-1.21.0 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/core/class_from_string.rb
fog-1.20.0 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/core/class_from_string.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/core/class_from_string.rb
fog-1.19.0 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/core/class_from_string.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/core/class_from_string.rb