Module | Sequel::Plugins::XmlSerializer::ClassMethods
In: | lib/sequel/plugins/xml_serializer.rb

### Methods

array_from_xml from_xml from_xml_node to_xml xml_builder xml_deserialize_name_proc xml_serialize_name_proc

### Constants

CAMELIZE | = | proc{|s| s.camelize} |  | Proc that camelizes the input string, used for the :camelize option
DASHERIZE | = | proc{|s| s.dasherize} |  | Proc that dasherizes the input string, used for the :dasherize option
IDENTITY | = | proc{|s| s} |  | Proc that returns the input string as is, used if no :name_proc, :dasherize, or :camelize option is used.
UNDERSCORE | = | proc{|s| s.underscore} |  | Proc that underscores the input string, used for the :underscore option

### Public Instance methods

array_from_xml(xml, opts={})

Return an array of instances of this class based on the provided XML.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 106
    106:         def array_from_xml(xml, opts={})
    107:           Nokogiri::XML(xml).children.first.children.reject{|c| c.is_a?(Nokogiri::XML::Text)}.map{|c| from_xml_node(c, opts)}
    108:         end

from_xml(xml, opts={})

Return an instance of this class based on the provided XML.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 112
    112:         def from_xml(xml, opts={})
    113:           from_xml_node(Nokogiri::XML(xml).children.first, opts)
    114:         end

from_xml_node(parent, opts={})

Return an instance of this class based on the given XML node, which should be Nokogiri::XML::Node instance. This should probably not be used directly by user code.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 119
    119:         def from_xml_node(parent, opts={})
    120:           new.from_xml_node(parent, opts)
    121:         end

to_xml(opts={})

Call the dataset `to_xml` method.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 124
    124:         def to_xml(opts={})
    125:           dataset.to_xml(opts)
    126:         end

xml_builder(opts={})

Return an appropriate Nokogiri::XML::Builder instance used to create the XML. This should probably not be used directly by user code.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 131
    131:         def xml_builder(opts={})
    132:           if opts[:builder]
    133:             opts[:builder]
    134:           else
    135:             builder_opts = if opts[:builder_opts]
    136:               opts[:builder_opts]
    137:             else
    138:               {}
    139:             end
    140:             builder_opts[:encoding] = opts[:encoding] if opts.has_key?(:encoding)
    141:             Nokogiri::XML::Builder.new(builder_opts)
    142:           end
    143:         end

xml_deserialize_name_proc(opts={})

Return a proc (or any other object that responds to []), used for formatting XML tag names when serializing to XML. This should probably not be used directly by user code.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 148
    148:         def xml_deserialize_name_proc(opts={})
    149:           if opts[:name_proc]
    150:             opts[:name_proc]
    151:           elsif opts[:underscore]
    152:             UNDERSCORE
    153:           else
    154:             IDENTITY
    155:           end
    156:         end

xml_serialize_name_proc(opts={})

Return a proc (or any other object that responds to []), used for formatting XML tag names when serializing to XML. This should probably not be used directly by user code.

[Source]

         # File lib/sequel/plugins/xml_serializer.rb, line 161
    161:         def xml_serialize_name_proc(opts={})
    162:           pr = if opts[:name_proc]
    163:             opts[:name_proc]
    164:           elsif opts[:dasherize]
    165:             DASHERIZE
    166:           elsif opts[:camelize]
    167:             CAMELIZE
    168:           else
    169:             IDENTITY
    170:           end
    171:           proc{|s| "#{pr[s]}_"}
    172:         end

[Validate]