Class: ActiveLdap::Xml::Serializer
- Inherits:
-
Object
- Object
- ActiveLdap::Xml::Serializer
- Defined in:
- lib/active_ldap/xml.rb
Constant Summary collapse
- PRINTABLE_STRING =
/[\x20-\x7e\w\s]*/
Instance Method Summary collapse
-
#initialize(dn, attributes, schema, options = {}) ⇒ Serializer
constructor
A new instance of Serializer.
- #to_s ⇒ Object
Constructor Details
#initialize(dn, attributes, schema, options = {}) ⇒ Serializer
Returns a new instance of Serializer.
11 12 13 14 15 16 |
# File 'lib/active_ldap/xml.rb', line 11 def initialize(dn, attributes, schema, ={}) @dn = dn @attributes = attributes @schema = schema @options = end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_ldap/xml.rb', line 18 def to_s root = @options[:root] indent = @options[:indent] || 2 xml = @options[:builder] || Builder::XmlMarkup.new(:indent => indent) xml.tag!(root) do target_attributes.each do |key, values| values = normalize_values(values).sort_by {|value, _| value} if @schema.attribute(key).single_value? serialize_attribute_value(xml, key, *values[0]) else serialize_attribute_values(xml, key, values) end end end end |