Module: Buby::Implants::Cookie

Defined in:
lib/buby/implants/cookie.rb

Overview

Note:

This module is used to extend the ICookie interface implementation java class at runtime.

This interface is used to hold details about an HTTP cookie.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implant(cookie) ⇒ Object

Install ourselves into the current ICookie java class

Parameters:

  • cookie (ICookie)

    instance



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/buby/implants/cookie.rb', line 21

def self.implant(cookie)
  unless cookie.implanted? || cookie.nil?
    pp [:implanting, cookie, cookie.class] if $DEBUG
    cookie.class.class_exec(cookie) do |cookie|
      a_methods = %w{
        getExpiration
      }
      a_methods.each do |meth|
        pp ["__" + meth, self] if $DEBUG
        alias_method "__"+meth.to_s, meth
      end
      include Buby::Implants::Cookie
      a_methods.each do |meth|
        pp [meth, self] if $DEBUG
        java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
          pp [ruby_meth, meth, self] if $DEBUG
          define_method ruby_meth, Buby::Implants::Cookie.instance_method(meth)
        end
      end
      include Buby::Implants::Proxy
    end
  end
  cookie
end

Instance Method Details

#getExpirationTime

This method is used to retrieve the expiration time for the cookie.

Returns:

  • (Time)

    The expiration time for the cookie, or nil if none is set (i.e., for non-persistent session cookies).



13
14
15
16
# File 'lib/buby/implants/cookie.rb', line 13

def getExpiration
  ret = __getExpiration
  ret.nil? ? ret : Time.at(ret.time/1000.0)
end