aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/test/fixtures/address.rb
blob: fe921e15955217050ef9da086da159f3db68ab5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# turns everyting 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