Sha256: 34c42a7ad465faa27c7d9d19efde655e6232e70d175190d06ce75208c80a16a5
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module Spectifly module Xsd class Association < Spectifly::Base::Association def name Spectifly::Support.camelize(@field_name).gsub(/\W/, '') end def to_xsd(builder = nil) builder ||= ::Builder::XmlMarkup.new(:indent => 2) if relationship =~ /^belongs_to(_many)?/ attributes['name'] = "#{name}Id" attributes['type'] = "xs:string" else attributes['name'] = name attributes['type'] = "#{Spectifly::Support.lower_camelize(type)}Type" end attributes['minOccurs'] = '0' unless required? attributes['maxOccurs'] = 'unbounded' if multiple? block = embedded_block builder.xs :element, attributes, &block end def embedded_block if description || example Proc.new { |el| if description || example el.xs :annotation do |ann| ann.xs :documentation, description if description ann.xs :documentation, "Example: #{example}" if example end end } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems