Sha256: 7dc09034d68a7d9a86473f57e350be9aed50ddf2f0cc9f0b88ec20f9fdc27322

Contents?: true

Size: 496 Bytes

Versions: 2

Compression:

Stored size: 496 Bytes

Contents

# frozen_string_literal: true

# turns everything into the same object
class AddressXMLFormatter
  include ActiveResource::Formats::XmlFormat

  def decode(xml)
    data = ActiveResource::Formats::XmlFormat.decode(xml)
    # process address fields
    data.each do |address|
      address["city_state"] = "#{address['city']}, #{address['state']}"
    end
    data
  end
end

class AddressResource < ActiveResource::Base
  self.element_name = "address"
  self.format = AddressXMLFormatter.new
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_cached_resource-0.1.0 lib/activeresource/test/fixtures/address.rb
active_cached_resource-0.0.1.pre lib/activeresource/test/fixtures/address.rb