lib/spectifly/xsd/builder.rb in spectifly-0.0.5 vs lib/spectifly/xsd/builder.rb in spectifly-0.0.6

- old
+ new

@@ -22,22 +22,31 @@ end end end end + def types + [ + fields.map(&:type) + + associations.select { |a| a.relationship != 'belongs_to' }.map(&:type) + ].flatten.compact.uniq + end + def build(xml = nil) xml ||= ::Builder::XmlMarkup.new(:indent => 2) xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8' xml.xs :schema, 'xmlns:xs' => "http://www.w3.org/2001/XMLSchema", 'elementFormDefault' => "qualified" do custom_types.each do |cust| xml.xs :include, 'schemaLocation' => "#{cust}.xsd" end unless utilized_extended_types.empty? xml.xs :include, 'schemaLocation' => "extended.xsd" end - xml.xs :element, :name => Spectifly::Support.camelize(root), :type => root_type + xml.xs :element, + :name => Spectifly::Support.camelize(root), + :type => root_type build_type(xml) end end end end -end \ No newline at end of file +end