Sha256: e57edac9393275b66c5fe4057e92697fae6f9b8513408d817b87f581c6d9f0a2

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

module ActiveresourceResponse
   module HttpResponse
       def headers
         @_active_resource_response_headers || symbolize_keys(to_hash)
       end
       def cookies
          unless @_active_resource_response_cookies
            @_active_resource_response_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
          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

1 entries across 1 versions & 1 rubygems

Version Path
activeresource-response-0.1.0 lib/activeresource-response/http_response.rb