Proc that camelizes the input string, used for the :camelize option
Proc that dasherizes the input string, used for the :dasherize option
Proc that returns the input string as is, used if no :name_proc, :dasherize, or :camelize option is used.
Proc that underscores the input string, used for the :underscore option
Return an array of instances of this class based on the provided XML.
# File lib/sequel/plugins/xml_serializer.rb, line 133 def array_from_xml(xml, opts={}) if opts[:all_associations] || opts[:all_columns] Sequel::Deprecation.deprecate("The array_from_xml :all_associations and :all_columns", 'You need to explicitly specify the associations and columns via the :associations and :fields options') end node = Nokogiri::XML(xml).children.first unless node raise Error, "Malformed XML used" end node.children.reject{|c| c.is_a?(Nokogiri::XML::Text)}.map{|c| from_xml_node(c, opts)} end
Return an instance of this class based on the provided XML.
# File lib/sequel/plugins/xml_serializer.rb, line 146 def from_xml(xml, opts={}) if opts[:all_associations] || opts[:all_columns] Sequel::Deprecation.deprecate("The from_xml :all_associations and :all_columns", 'You need to explicitly specify the associations and columns via the :associations and :fields options') end from_xml_node(Nokogiri::XML(xml).children.first, opts) end
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.
# File lib/sequel/plugins/xml_serializer.rb, line 156 def from_xml_node(parent, opts={}) new.from_xml_node(parent, opts) end
Return an appropriate Nokogiri::XML::Builder instance used to create the XML. This should probably not be used directly by user code.
# File lib/sequel/plugins/xml_serializer.rb, line 163 def xml_builder(opts={}) if opts[:builder] opts[:builder] else builder_opts = if opts[:builder_opts] opts[:builder_opts] else {} end builder_opts[:encoding] = opts[:encoding] if opts.has_key?(:encoding) Nokogiri::XML::Builder.new(builder_opts) end end
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.
# File lib/sequel/plugins/xml_serializer.rb, line 180 def xml_deserialize_name_proc(opts={}) if opts[:name_proc] opts[:name_proc] elsif opts[:underscore] UNDERSCORE else IDENTITY end end
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.
# File lib/sequel/plugins/xml_serializer.rb, line 193 def xml_serialize_name_proc(opts={}) pr = if opts[:name_proc] opts[:name_proc] elsif opts[:dasherize] DASHERIZE elsif opts[:camelize] CAMELIZE else IDENTITY end proc{|s| "#{pr[s]}_"} end
Generated with the Darkfish Rdoc Generator 2.