Sha256: 3e470b112bfa9f7821ebd0395be7ccedd8ace177b4db01f13bc99111b98b75c9

Contents?: true

Size: 650 Bytes

Versions: 70

Compression:

Stored size: 650 Bytes

Contents

module ActiveResource
  module Formats
    module XmlFormat
      extend self

      def extension
        "xml"
      end

      def mime_type
        "application/xml"
      end

      def encode(hash, options={})
        hash.to_xml(options)
      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 Active Resource.
        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

70 entries across 67 versions & 11 rubygems

Version Path
activeresource-2.3.18 lib/active_resource/formats/xml_format.rb
activeresource_csi-2.3.5.p8 lib/active_resource/formats/xml_format.rb
activeresource-2.3.17 lib/active_resource/formats/xml_format.rb
activeresource_csi-2.3.5.p7 lib/active_resource/formats/xml_format.rb
activeresource_csi-2.3.5.20130130071128 lib/active_resource/formats/xml_format.rb
activeresource_csi-2.3.5.p6 lib/active_resource/formats/xml_format.rb
activeresource-2.3.16 lib/active_resource/formats/xml_format.rb
activeresource-2.3.15 lib/active_resource/formats/xml_format.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/activeresource-2.3.14/lib/active_resource/formats/xml_format.rb
vanity-1.7.1 vendor/ruby/1.9.1/gems/activeresource-2.3.12/lib/active_resource/formats/xml_format.rb
activeresource-2.3.14 lib/active_resource/formats/xml_format.rb
kajam-1.0.3.rc2 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
activeresource-2.3.12 lib/active_resource/formats/xml_format.rb
radiant-1.0.0.rc2 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiant-1.0.0.rc1 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
webroar-0.5.0 src/admin_panel/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
activeresource-2.3.11 lib/active_resource/formats/xml_format.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb