Sha256: ad41bb74e0bdcc5e134169e848e335d21158b393fde67cb1bf1fc1c7a8c7bf99

Contents?: true

Size: 1.44 KB

Versions: 5

Compression:

Stored size: 1.44 KB

Contents

class Buby
  module Implants
    # This interface is used to retrieve key details about an HTTP response.
    # Extensions can obtain an +IResponseInfo+ object for a given response by calling
    # <code>IExtensionHelpers.analyzeResponse()</code>.
    #
    module ResponseInfo
      # This method is used to obtain details of the HTTP cookies set in the
      # response.
      #
      # @return [ICookie] A list of +ICookie+ objects representing the cookies
      #   set in the response, if any.
      #
      def getCookies
        __getCookies.tap{|cookies| Buby::Implants::Cookie.implant(cookies.first)}
      end

      # Install ourselves into the current +IResponseInfo+ java class
      # @param [IResponseInfo] info
      #
      def self.implant(info)
        unless info.implanted? || info.nil?
          pp [:implanting, info, info.class] if $DEBUG
          info.class.class_exec(info) do |info|
            a_methods = %w{
              getCookies
            }
            a_methods.each do |meth|
              alias_method "__"+meth.to_s, meth
            end
            include Buby::Implants::ResponseInfo
            a_methods.each do |meth|
              java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
                define_method ruby_meth, Buby::Implants::ResponseInfo.instance_method(meth)
              end
            end
            include Buby::Implants::Proxy
          end
        end
        info
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
buby-1.5.2-java lib/buby/implants/response_info.rb
buby-1.5.1-java lib/buby/implants/response_info.rb
buby-1.5.0-java lib/buby/implants/response_info.rb
buby-1.5.0.pre4-java lib/buby/implants/response_info.rb
buby-1.5.0.pre3-java lib/buby/implants/response_info.rb