lib/spectifly/xsd/association.rb in spectifly-0.0.5 vs lib/spectifly/xsd/association.rb in spectifly-0.0.6
- old
+ new
@@ -5,15 +5,21 @@
Spectifly::Support.camelize(@field_name).gsub(/\W/, '')
end
def to_xsd(builder = nil)
builder ||= ::Builder::XmlMarkup.new(:indent => 2)
- attributes['type'] = "#{Spectifly::Support.lower_camelize(type)}Type"
- attributes['minOccurs'] = '0' unless required? && relationship != 'belongs_to'
+ if relationship == 'belongs_to'
+ attributes['name'] = "#{name}Id"
+ attributes['type'] = "xs:string"
+ else
+ attributes['name'] = name
+ attributes['type'] = "#{Spectifly::Support.lower_camelize(type)}Type"
+ attributes['minOccurs'] = '0' unless required?
+ end
attributes['maxOccurs'] = 'unbounded' if multiple?
block = embedded_block
- builder.xs :element, { :name => name }.merge(attributes), &block
+ builder.xs :element, attributes, &block
end
def embedded_block
if description || example
Proc.new { |el|
@@ -26,6 +32,6 @@
}
end
end
end
end
-end
\ No newline at end of file
+end