Module: MyData::Xsd::Structure
Constant Summary collapse
Instance Method Summary collapse
- #complex_types ⇒ Object
- #doc(class_name) ⇒ Object
- #docs ⇒ Object
- #resource_attributes(class_name, type) ⇒ Object
- #simple_types ⇒ Object
Instance Method Details
#complex_types ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/my_data/xsd/structure.rb', line 28 def complex_types @complex_types ||= docs.values.each_with_object({}) do |document, types| document.complex_types.each do |type| name = [type.namespace, type.name].compact.join(":") types[name] = type end end end |
#doc(class_name) ⇒ Object
8 9 10 11 |
# File 'lib/my_data/xsd/structure.rb', line 8 def doc(class_name) name = class_name.split("::").last [name, docs[name]] end |
#docs ⇒ Object
22 23 24 25 26 |
# File 'lib/my_data/xsd/structure.rb', line 22 def docs @docs ||= Dir.glob("*.xsd", base: PATH).to_h do |file_name| [file_name.sub(/-.+$/, "").camelize, MyData::Xsd::Doc.new(read_xsd(file_name))] end end |
#resource_attributes(class_name, type) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/my_data/xsd/structure.rb', line 13 def resource_attributes(class_name, type) namespace, name = class_name.split("::").last(2) key = namespace == "Resources" ? name : [namespace.downcase, name].join(":") current_doc = type == :complex_type ? complex_types[key] : docs[name] current_doc.elements.map { |element| element_attributes(element) } end |
#simple_types ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/my_data/xsd/structure.rb', line 37 def simple_types @simple_types ||= docs.values.each_with_object({}) do |document, types| document.simple_types.each do |type| name = [type.namespace, type.name].compact.join(":") types[name] = type end end end |