Module: SoftLayer

Defined in:
lib/softlayer.rb

Defined Under Namespace

Classes: BaseClass, Exception, ObjectMask, Param, ResultLimit

Class Method Summary collapse

Class Method Details

.ClassFactory(args) ⇒ Object

Create a Ruby class to match an SLAPI WSDL endpoint. Args:

class

The name of the class to create in Ruby format.

parent

The parent namespace to add the class to (this should be somewere in SoftLayer; optional).

This recursively walks up class creating them as needed, so SoftLayer::Dns::Domain will create classes for Dns and Domain (even though the Dns class will never be used).



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/softlayer.rb', line 70

def SoftLayer::ClassFactory(args)
  cname = args[:class]
  parent = args[:parent] unless args[:parent].nil?

  cary = cname.split('::')
  parent = const_get(cary.shift) if parent.nil? # This should always be SoftLayer, but maybe not...
  cur = cary.shift
  newclass = nil
  unless parent.const_defined?(cur)
    newclass = SoftLayer::makeSLAPIKlass(:class => cur, :parent => parent)
  else
    newclass = parent.const_get(cur)
  end
  return newclass if cary.empty?

  left = cary.join('::')
  k = SoftLayer::ClassFactory(:class => left, :parent => newclass) 
  return k
end

.declareClasses(args) ⇒ Object

Declare SLAPI clases. Args take class names in two forms:

soap

Service names in SOAP format (example: SoftLayer_Account)

ruby

Class names in Ruby format (example: SoftLayer::Account)

Creates the class, and retrieves and caches the endpoint WSDL.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/softlayer.rb', line 47

def SoftLayer::declareClasses(args)
  classes = args[:ruby]
  services = args[:soap]

  unless (services.nil? || services.empty?)
    services.each do |s|
      c = s.gsub(/_/,'::')
      classes.push(c)
    end
  end

  classes.each do |cstr|
    k = SoftLayer::ClassFactory(:class => cstr)
    k.cacheWSDL
  end
end

.makeSLAPIKlass(args) ⇒ Object

This really creates the class.

class

The name of the class to create in Ruby format.

parent

The parent namespace to add the class to (this should be somewhere in SoftLayer, not optional).



93
94
95
96
97
98
99
100
101
102
# File 'lib/softlayer.rb', line 93

def SoftLayer::makeSLAPIKlass(args)
  cname = args[:class]
  parent = args[:parent]
  realKlassName = "#{cname}"
  klass = Class.new SoftLayer::BaseClass do 

  end
  parent.const_set realKlassName, klass
  return klass
end