Sha256: a0f2e867c64c10cc6f1e7e5d6bc4de68e89d48abdb560ae60ddc38c98926d3e8

Contents?: true

Size: 903 Bytes

Versions: 2

Compression:

Stored size: 903 Bytes

Contents

module ActiveresourceResponse
   module HttpResponse
       def headers
         @_active_resource_response_headers || symbolize_keys(to_hash)
       end
       def cookies
          unless @_active_resource_response_cookies
             cookies   = (self.headers[:set_cookie] || {}).inject({}) do |out, cookie_str|    
               CGI::Cookie::parse(cookie_str).each do |key, cookie|  
                 out[key] = cookie.value.first unless ['expires', 'path'].include? key 
               end
               out
            end
            @_active_resource_response_cookies = symbolize_keys(cookies)
          end  
          @_active_resource_response_cookies
       end
       
       private
       def symbolize_keys(hash)
         hash.inject({}) do |out, (key, value)|
             out[key.gsub(/-/, '_').downcase.to_sym] = value
             out
         end
       end   
       
   end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activeresource-response-0.0.9 lib/activeresource-response/http_response.rb
activeresource-response-0.0.8 lib/activeresource-response/http_response.rb