diff options
author | Rasik Pandey <rbpandey@gmail.com> | 2008-08-30 04:19:18 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-29 18:45:39 -0700 |
commit | 16b9a554db7e1bf3f5f224cdc5b4d27480e053ff (patch) | |
tree | 7eef718fa623a5fcebb90de534b0eba2a6eae020 /activeresource/lib/active_resource/base.rb | |
parent | 11eb29f60ab79caf22f7ca715500e32d9a1b03a2 (diff) | |
download | rails-16b9a554db7e1bf3f5f224cdc5b4d27480e053ff.tar.gz rails-16b9a554db7e1bf3f5f224cdc5b4d27480e053ff.tar.bz2 rails-16b9a554db7e1bf3f5f224cdc5b4d27480e053ff.zip |
Format related patches to support serializing data out in the correct format with correct http request headers per http method type [#450 state:resolved]
Signed-off-by: Tarmo Tänav <tarmo@itech.ee>
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 4af30ea13f..fb23b13fbb 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -848,8 +848,13 @@ module ActiveResource # # my_group.to_xml(:skip_instruct => true) # # => <subsidiary_group> [...] </subsidiary_group> - def to_xml(options={}) - attributes.to_xml({:root => self.class.element_name}.merge(options)) + def encode(options={}) + case self.class.format + when ActiveResource::Formats[:xml] + self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options)) + else + self.class.format.encode(attributes, options) + end end # A method to reload the attributes of this object from the remote web service. @@ -934,14 +939,14 @@ module ActiveResource # Update the resource on the remote service. def update - returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response| + returning connection.put(element_path(prefix_options), encode, self.class.headers) do |response| load_attributes_from_response(response) end end # Create (i.e., save to the remote service) the new resource. def create - returning connection.post(collection_path, to_xml, self.class.headers) do |response| + returning connection.post(collection_path, encode, self.class.headers) do |response| self.id = id_from_response(response) load_attributes_from_response(response) end |