Sha256: a0967fe2b8c9a4f8e8b6dba73322d79fbdd18ad3d0b35fb8c8b404cf0d197be9

Contents?: true

Size: 663 Bytes

Versions: 20

Compression:

Stored size: 663 Bytes

Contents

module ActiveResource
  module Formats
    module XmlFormat
      extend self
      
      def extension
        "xml"
      end
      
      def mime_type
        "application/xml"
      end
      
      def encode(hash)
        hash.to_xml
      end
      
      def decode(xml)
        from_xml_data(Hash.from_xml(xml))
      end
      
      private
        # Manipulate from_xml Hash, because xml_simple is not exactly what we
        # want for ActiveResource.
        def from_xml_data(data)
          if data.is_a?(Hash) && data.keys.size == 1
            data.values.first
          else
            data
          end
        end      
    end
  end
end

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
activeresource-2.0.1 lib/active_resource/formats/xml_format.rb
activeresource-2.0.4 lib/active_resource/formats/xml_format.rb
activeresource-2.0.2 lib/active_resource/formats/xml_format.rb
activeresource-2.0.5 lib/active_resource/formats/xml_format.rb
radiant-0.6.5.1 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-0.6.5 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-0.6.6 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-0.6.7 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-0.6.8 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-0.6.9 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
spree-0.0.9 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
spree-0.2.0 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
swivel-0.0.149 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.150 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.156 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.160 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.157 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.155 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb
swivel-0.0.175 vendor/activeresource/lib/active_resource/formats/xml_format.rb
swivel-0.0.152 vendor/activeresource-2.0.2-/lib/active_resource/formats/xml_format.rb