Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6625

Show
Ignore:
Timestamp:
04/29/07 04:46:14 (2 years ago)
Author:
rick
Message:

change #custom_headers to just #headers [Rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activeresource/CHANGELOG

    r6624 r6625  
    44 
    55  class Project 
    6     custom_headers['X-Token'] = 'foo' 
     6    headers['X-Token'] = 'foo' 
    77  end 
    88   
  • trunk/activeresource/lib/active_resource/base.rb

    r6624 r6625  
    3030      end 
    3131 
    32       def custom_headers 
    33         @custom_headers ||= {} 
     32      def headers 
     33        @headers ||= {} 
    3434      end 
    3535 
     
    155155          from ||= collection_path(prefix_options, query_options) 
    156156 
    157           instantiate_collection(connection.get(from, custom_headers) || []) 
     157          instantiate_collection(connection.get(from, headers) || []) 
    158158        end 
    159159         
     
    172172          from = scope.to_s.include?("/") ? scope : element_path(scope, prefix_options, query_options) 
    173173 
    174           returning new(connection.get(from, custom_headers)) do |resource| 
     174          returning new(connection.get(from, headers)) do |resource| 
    175175            resource.prefix_options = prefix_options 
    176176          end 
     
    259259    # Delete the resource. 
    260260    def destroy 
    261       connection.delete(element_path, self.class.custom_headers) 
     261      connection.delete(element_path, self.class.headers) 
    262262    end 
    263263 
     
    305305      # Update the resource on the remote service. 
    306306      def update 
    307         returning connection.put(element_path(prefix_options), to_xml, self.class.custom_headers) do |response| 
     307        returning connection.put(element_path(prefix_options), to_xml, self.class.headers) do |response| 
    308308          load_attributes_from_response(response) 
    309309        end 
     
    312312      # Create (i.e., save to the remote service) the new resource. 
    313313      def create 
    314         returning connection.post(collection_path, to_xml, self.class.custom_headers) do |response| 
     314        returning connection.post(collection_path, to_xml, self.class.headers) do |response| 
    315315          self.id = id_from_response(response) 
    316316          load_attributes_from_response(response) 
  • trunk/activeresource/lib/active_resource/custom_methods.rb

    r6624 r6625  
    3737           
    3838          def get(method_name, options = {}) 
    39             connection.get(custom_method_collection_url(method_name, options), custom_headers) 
     39            connection.get(custom_method_collection_url(method_name, options), headers) 
    4040          end 
    4141       
    4242          def post(method_name, options = {}, body = nil) 
    43             connection.post(custom_method_collection_url(method_name, options), body, custom_headers) 
     43            connection.post(custom_method_collection_url(method_name, options), body, headers) 
    4444          end 
    4545       
    4646          def put(method_name, options = {}, body = nil) 
    47             connection.put(custom_method_collection_url(method_name, options), body, custom_headers) 
     47            connection.put(custom_method_collection_url(method_name, options), body, headers) 
    4848          end 
    4949       
     
    5151          def delete(custom_method_name, options = {}) 
    5252            if (custom_method_name.is_a?(Symbol)) 
    53               connection.delete(custom_method_collection_url(custom_method_name, options), custom_headers) 
     53              connection.delete(custom_method_collection_url(custom_method_name, options), headers) 
    5454            else 
    5555              orig_delete(custom_method_name, options) 
     
    7272    module InstanceMethods 
    7373      def get(method_name, options = {}) 
    74         connection.get(custom_method_element_url(method_name, options), self.class.custom_headers) 
     74        connection.get(custom_method_element_url(method_name, options), self.class.headers) 
    7575      end 
    7676       
    7777      def post(method_name, options = {}, body = nil) 
    7878        if new? 
    79           connection.post(custom_method_new_element_url(method_name, options), (body.nil? ? to_xml : body), self.class.custom_headers) 
     79          connection.post(custom_method_new_element_url(method_name, options), (body.nil? ? to_xml : body), self.class.headers) 
    8080        else 
    81           connection.post(custom_method_element_url(method_name, options), body, self.class.custom_headers) 
     81          connection.post(custom_method_element_url(method_name, options), body, self.class.headers) 
    8282        end 
    8383      end 
    8484       
    8585      def put(method_name, options = {}, body = nil) 
    86         connection.put(custom_method_element_url(method_name, options), body, self.class.custom_headers) 
     86        connection.put(custom_method_element_url(method_name, options), body, self.class.headers) 
    8787      end 
    8888       
    8989      def delete(method_name, options = {}) 
    90         connection.delete(custom_method_element_url(method_name, options), self.class.custom_headers) 
     90        connection.delete(custom_method_element_url(method_name, options), self.class.headers) 
    9191      end 
    9292 
  • trunk/activeresource/test/base_test.rb

    r6624 r6625  
    201201 
    202202  def test_custom_header 
    203     Person.custom_headers['key'] = 'value' 
     203    Person.headers['key'] = 'value' 
    204204    assert_raises(ActiveResource::ResourceNotFound) { Person.find(3) } 
    205205  ensure 
    206     Person.custom_headers.delete('key') 
     206    Person.headers.delete('key') 
    207207  end 
    208208