Class: Shale::Schema::XMLGenerator::Attribute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/shale/schema/xml_generator/attribute.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class representing XML Schema <attribute> element. Serves as a base class for TypedAttribute and RefAttribute

Direct Known Subclasses

RefAttribute, TypedAttribute

Instance Method Summary collapse

Constructor Details

#initialize(default) ⇒ Attribute

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize Attribute object

Parameters:

  • default (String, nil)


16
17
18
# File 'lib/shale/schema/xml_generator/attribute.rb', line 16

def initialize(default)
  @default = default
end

Instance Method Details

#as_xml(doc) ⇒ Shale::Adapter::<XML adapter>::Node

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Append element to the XML document

Parameters:

Returns:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/shale/schema/xml_generator/attribute.rb', line 27

def as_xml(doc)
  attribute = doc.create_element('xs:attribute')

  attributes.each do |name, value|
    doc.add_attribute(attribute, name, value)
  end

  doc.add_attribute(attribute, 'default', @default) unless @default.nil?

  attribute
end