Class: WsdlMapper::Dom::Schema

Inherits:
Object
  • Object
show all
Includes:
WsdlMapper::Dom
Defined in:
lib/wsdl_mapper/dom/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSchema

Returns a new instance of Schema.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wsdl_mapper/dom/schema.rb', line 13

def initialize
  @types = Directory.new
  @anon_types = []
  @elements = Directory.new
  @attributes = Directory.new
  @builtin_types = Directory.new
  @soap_encoding_types = Directory.new
  @qualified_elements = false
  @qualified_attributes = false
  @imports = []
  @unresolved_imports = []
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/wsdl_mapper/dom/schema.rb', line 10

def attributes
  @attributes
end

#elementsObject (readonly)

Returns the value of attribute elements.



10
11
12
# File 'lib/wsdl_mapper/dom/schema.rb', line 10

def elements
  @elements
end

#importsObject (readonly)

Returns the value of attribute imports.



10
11
12
# File 'lib/wsdl_mapper/dom/schema.rb', line 10

def imports
  @imports
end

#qualified_attributesObject

Returns the value of attribute qualified_attributes.



11
12
13
# File 'lib/wsdl_mapper/dom/schema.rb', line 11

def qualified_attributes
  @qualified_attributes
end

#qualified_elementsObject

Returns the value of attribute qualified_elements.



11
12
13
# File 'lib/wsdl_mapper/dom/schema.rb', line 11

def qualified_elements
  @qualified_elements
end

#target_namespaceObject

Returns the value of attribute target_namespace.



11
12
13
# File 'lib/wsdl_mapper/dom/schema.rb', line 11

def target_namespace
  @target_namespace
end

#typesObject (readonly)

Returns the value of attribute types.



10
11
12
# File 'lib/wsdl_mapper/dom/schema.rb', line 10

def types
  @types
end

#unresolved_importsObject (readonly)

Returns the value of attribute unresolved_imports.



10
11
12
# File 'lib/wsdl_mapper/dom/schema.rb', line 10

def unresolved_imports
  @unresolved_imports
end

Instance Method Details

#add_attribute(attr) ⇒ Object



43
44
45
# File 'lib/wsdl_mapper/dom/schema.rb', line 43

def add_attribute(attr)
  @attributes[attr.name] = attr
end

#add_element(element) ⇒ Object



39
40
41
# File 'lib/wsdl_mapper/dom/schema.rb', line 39

def add_element(element)
  @elements[element.name] = element
end

#add_import(_, schema) ⇒ Object



26
27
28
# File 'lib/wsdl_mapper/dom/schema.rb', line 26

def add_import(_, schema)
  @imports << schema
end

#add_type(type) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/wsdl_mapper/dom/schema.rb', line 30

def add_type(type)
  if type.name
    @types[type.name] = type
  else
    @anon_types << type
  end
  type
end

#each_attribute(&block) ⇒ Object



91
92
93
# File 'lib/wsdl_mapper/dom/schema.rb', line 91

def each_attribute(&block)
  recursive_each @attributes, :each_attribute, &block
end

#each_builtin_type(&block) ⇒ Object



95
96
97
# File 'lib/wsdl_mapper/dom/schema.rb', line 95

def each_builtin_type(&block)
  @builtin_types.values.each(&block)
end

#each_element(&block) ⇒ Object



87
88
89
# File 'lib/wsdl_mapper/dom/schema.rb', line 87

def each_element(&block)
  recursive_each @elements, :each_element, &block
end

#each_soap_encoding_type(&block) ⇒ Object



99
100
101
# File 'lib/wsdl_mapper/dom/schema.rb', line 99

def each_soap_encoding_type(&block)
  @soap_encoding_types.values.each(&block)
end

#each_type(&block) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/wsdl_mapper/dom/schema.rb', line 69

def each_type(&block)
  enum = Enumerator.new do |y|
    @types.each do |(_, t)|
      y << t
    end
    @anon_types.each do |t|
      y << t
    end
    @imports.each do |i|
      i.each_type do |t|
        y << t
      end
    end
  end

  block_given? ? enum.each(&block) : enum
end

#get_attribute(name) ⇒ Object



65
66
67
# File 'lib/wsdl_mapper/dom/schema.rb', line 65

def get_attribute(name)
  @attributes[name] || @imports.lazy.map { |s| s.get_attribute(name) }.reject(&:nil?).first
end

#get_element(name) ⇒ Object



61
62
63
# File 'lib/wsdl_mapper/dom/schema.rb', line 61

def get_element(name)
  @elements[name] || @imports.lazy.map { |s| s.get_element(name) }.reject(&:nil?).first
end

#get_type(name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wsdl_mapper/dom/schema.rb', line 47

def get_type(name)
  return if name.nil?

  if name.ns == BuiltinType::NAMESPACE
    @builtin_types[name] ||= BuiltinType.types[name]
  elsif name.ns == SoapEncodingType::NAMESPACE
    @soap_encoding_types[name] ||= SoapEncodingType.types[name]
  elsif (type = @types[name])
    type
  else
    @imports.lazy.map { |s| s.get_type(name) }.reject(&:nil?).first
  end
end