1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activeresource/test/fixtures/address.rb
2011-03-05 11:56:34 +01:00

19 lines
No EOL
465 B
Ruby

# 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