class WsdlMapper::Dom::Schema
Attributes
attributes[R]
elements[R]
imports[R]
qualified_attributes[RW]
qualified_elements[RW]
target_namespace[RW]
types[R]
unresolved_imports[R]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
add_attribute(attr)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 43 def add_attribute(attr) @attributes[attr.name] = attr end
add_element(element)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 39 def add_element(element) @elements[element.name] = element end
add_import(_, schema)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 26 def add_import(_, schema) @imports << schema end
add_type(type)
click to toggle source
# 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)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 91 def each_attribute(&block) recursive_each @attributes, :each_attribute, &block end
each_builtin_type(&block)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 95 def each_builtin_type(&block) @builtin_types.values.each(&block) end
each_element(&block)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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
Protected Instance Methods
recursive_each(array, accessor, &block)
click to toggle source
# File lib/wsdl_mapper/dom/schema.rb, line 104 def recursive_each(array, accessor, &block) enum = Enumerator.new do |y| array.each do |(_, t)| y << t end @imports.each do |i| i.send(accessor) do |t| y << t end end end block_given? ? enum.each(&block) : enum end