Module: Fog::Vsphere
- Extended by:
- Provider
- Defined in:
- lib/fog/vsphere/core.rb
Defined Under Namespace
Modules: Errors
Class Method Summary collapse
-
.class_from_string(classname, defaultpath = "") ⇒ Object
This helper was originally added as Fog.class_as_string and moved to core but only used here.
Class Method Details
.class_from_string(classname, defaultpath = "") ⇒ Object
This helper was originally added as Fog.class_as_string and moved to core but only used here
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/vsphere/core.rb', line 16 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 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 ? class_from_string((defaultpath.split("::")+chain).join("::"), nil) : nil end |