Sha256: 3f496e10b3894b5f88116271161726776073fa2d5f394f859a0f57ba2c351945

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'fog/core'

module Fog
  module Vsphere
    autoload :Compute, File.expand_path('../vsphere/compute', __FILE__)

    extend Fog::Provider

    module Errors
      class ServiceError < Fog::Errors::Error; end
      class SecurityError < ServiceError; end
      class NotFound < ServiceError; end
    end

    service(:compute, 'Compute')

    # This helper was originally added as Fog.class_as_string and moved to core but only used here
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-vsphere-0.3.0 lib/fog/vsphere.rb
fog-vsphere-0.2.0 lib/fog/vsphere.rb
fog-vsphere-0.1.1 lib/fog/vsphere.rb
fog-vsphere-0.1.0 lib/fog/vsphere.rb