def encode(object, options={})
      object = object.to_a if defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)
      fields_to_hash(options)
      if object.is_a?(Array)
        if options[:fields]
          encode_partial_array(object, options)
        else
          encode_array(object, options)
        end
      elsif options[:fields]
        encode_partial_single(object, options)
      else
        encode_single(object, options)
      end
    end
def encode(object, options={})
      object = object.to_a if defined?(ActiveRecord::Relation) && object.is_a?(ActiveRecord::Relation)
      fields_to_hash(options)
      if object.is_a?(Array)
        if options[:fields]
          encode_partial_array(object, options)
        else
          encode_array(object, options)
        end
      elsif options[:fields]
        encode_partial_single(object, options)
      else
        encode_single(object, options)
      end
    end
Creates a new XML-encoder with a root tag named after +root_name+.

 @example Create a simple encoder for a person with a name attribute:
   Pump::Xml.new :person do
     tag :name
   end

 @example Create the same without usage of the DSL:
   Pump::Xml.new :person, [{:name => :name}]

 @example Create the same but without the xml instruct
   Pump::Xml.new :person, :instruct => false do
     tag :name
   end

 @example The same again without DSL:

   Pump::Xml.new :person, [{:name => :name}], :instruct => false

 @param [String, Symbol] root_name         the name of the used root tag
 @param [Array<Hash>] encoder_config       optional config for all tags
 @param [Hash] encoder_options             optional encoder_options for the whole encoder
 @yield an optional block to create the encoder with the Pump::Dsl

 @return [self]
 Encode a object or an array of objects to an formatted string.

 @param [Object, Array<Object>] object object or an array of objects to
    encode to XML or JSON. The only requirement: The given objects must respond
    to all methods configured during initalization of the Pump::Xml or Pump::JSON instance.

 @return [String]