Class: Spectifly::Xsd::Association
- Inherits:
-
Base::Association
- Object
- Base::EntityNode
- Base::Association
- Spectifly::Xsd::Association
- Defined in:
- lib/spectifly/xsd/association.rb
Instance Attribute Summary
Attributes inherited from Base::Association
Attributes inherited from Base::EntityNode
#attributes, #description, #example, #inherits_from, #restrictions, #validations
Instance Method Summary collapse
Methods inherited from Base::Association
Methods inherited from Base::EntityNode
#display_type, #extract_attributes, #extract_restrictions, #initialize, #required?, #type, #unique?
Constructor Details
This class inherits a constructor from Spectifly::Base::Association
Instance Method Details
#embedded_block ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spectifly/xsd/association.rb', line 23 def 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 |
#name ⇒ Object
4 5 6 |
# File 'lib/spectifly/xsd/association.rb', line 4 def name Spectifly::Support.camelize(@field_name).gsub(/\W/, '') end |
#to_xsd(builder = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/spectifly/xsd/association.rb', line 8 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 = builder.xs :element, attributes, &block end |