diff options
Diffstat (limited to 'activeresource/lib/active_resource/base.rb')
-rw-r--r-- | activeresource/lib/active_resource/base.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index bcc1e8b497..5a2c54c5ec 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -29,6 +29,10 @@ module ActiveResource @connection end + def custom_headers + @custom_headers ||= {} + end + # Do not include any modules in the default element name. This makes it easier to seclude ARes objects # in a separate namespace without having to set element_name repeatedly. attr_accessor_with_default(:element_name) { to_s.split("::").last.underscore } #:nodoc: @@ -150,7 +154,7 @@ module ActiveResource prefix_options, query_options = split_options(options) from ||= collection_path(prefix_options, query_options) - instantiate_collection(connection.get(from) || []) + instantiate_collection(connection.get(from, custom_headers) || []) end def instantiate_collection(collection, prefix_options = {}) @@ -167,7 +171,7 @@ module ActiveResource prefix_options, query_options = split_options(options) from = scope.to_s.include?("/") ? scope : element_path(scope, prefix_options, query_options) - returning new(connection.get(from)) do |resource| + returning new(connection.get(from, custom_headers)) do |resource| resource.prefix_options = prefix_options end end @@ -254,7 +258,7 @@ module ActiveResource # Delete the resource. def destroy - connection.delete(element_path) + connection.delete(element_path, self.class.custom_headers) end # Evaluates to <tt>true</tt> if this resource is found. @@ -300,14 +304,14 @@ module ActiveResource # Update the resource on the remote service. def update - returning connection.put(element_path(prefix_options), to_xml) do |response| + returning connection.put(element_path(prefix_options), to_xml, self.class.custom_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) do |response| + returning connection.post(collection_path, to_xml, self.class.custom_headers) do |response| self.id = id_from_response(response) load_attributes_from_response(response) end |