Class: WsdlMapper::Dom::Schema
- Inherits:
-
Object
- Object
- WsdlMapper::Dom::Schema
- Includes:
- WsdlMapper::Dom
- Defined in:
- lib/wsdl_mapper/dom/schema.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#imports ⇒ Object
readonly
Returns the value of attribute imports.
-
#qualified_attributes ⇒ Object
Returns the value of attribute qualified_attributes.
-
#qualified_elements ⇒ Object
Returns the value of attribute qualified_elements.
-
#target_namespace ⇒ Object
Returns the value of attribute target_namespace.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
-
#unresolved_imports ⇒ Object
readonly
Returns the value of attribute unresolved_imports.
Instance Method Summary collapse
- #add_attribute(attr) ⇒ Object
- #add_element(element) ⇒ Object
- #add_import(_, schema) ⇒ Object
- #add_type(type) ⇒ Object
- #each_attribute(&block) ⇒ Object
- #each_builtin_type(&block) ⇒ Object
- #each_element(&block) ⇒ Object
- #each_soap_encoding_type(&block) ⇒ Object
- #each_type(&block) ⇒ Object
- #get_attribute(name) ⇒ Object
- #get_element(name) ⇒ Object
- #get_type(name) ⇒ Object
-
#initialize ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize ⇒ Schema
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/wsdl_mapper/dom/schema.rb', line 10 def attributes @attributes end |
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
10 11 12 |
# File 'lib/wsdl_mapper/dom/schema.rb', line 10 def elements @elements end |
#imports ⇒ Object (readonly)
Returns the value of attribute imports.
10 11 12 |
# File 'lib/wsdl_mapper/dom/schema.rb', line 10 def imports @imports end |
#qualified_attributes ⇒ Object
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_elements ⇒ Object
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_namespace ⇒ Object
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 |
#types ⇒ Object (readonly)
Returns the value of attribute types.
10 11 12 |
# File 'lib/wsdl_mapper/dom/schema.rb', line 10 def types @types end |
#unresolved_imports ⇒ Object (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 |