Class: WSDL::SOAP::ClassNameCreator

Inherits:
Object
  • Object
show all
Includes:
XSD::CodeGen::GenSupport
Defined in:
lib/wsdl/soap/classNameCreator.rb

Instance Method Summary collapse

Methods included from XSD::CodeGen::GenSupport

capitalize, constant?, #format, keyword?, safeconstname, safeconstname?, safemethodname, safemethodname?, safevarname, safevarname?, uncapitalize

Constructor Details

#initializeClassNameCreator

Returns a new instance of ClassNameCreator.



21
22
23
# File 'lib/wsdl/soap/classNameCreator.rb', line 21

def initialize
  @classname = {}
end

Instance Method Details

#assign_name(qname, modulepath = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wsdl/soap/classNameCreator.rb', line 25

def assign_name(qname, modulepath = nil)
  key = [modulepath, qname]
  unless @classname.key?(key)
    if klass = ::SOAP::TypeMap[qname]
      name =
        ::SOAP::Mapping::DefaultRegistry.find_mapped_obj_class(klass).name
    else
      name = safeconstname(qname.name)
      if modulepath
        name = [modulepath, name].join('::')
      end
      while @classname.value?(name)
        name += '_'
      end
      check_classname(name)
    end
    @classname[key] = name.freeze
  end
  @classname[key]
end

#check_classname(name) ⇒ Object



46
47
48
49
50
# File 'lib/wsdl/soap/classNameCreator.rb', line 46

def check_classname(name)
  if Object.constants.include?(name)
    warn("created definition re-opens an existing toplevel class: #{name}.  consider to use --module_path option of wsdl2ruby.rb")
  end
end