class Php_process::Proxy_obj

This object proxies calls to the object it refers to on the PHP-side. It is automatically spawned from “php.new” and should not be spawned manually.

Examples

php = Php_process.new
pe = php.new("PHPExcel")
pe.getProperties.setCreator("kaspernj")

Attributes

args[R]

Contains the various data about the object like ID and class. It is readable because it needs to be converted to special hashes when used as arguments.

Public Class Methods

new(args) click to toggle source

Sets required instance-variables and defines the finalizer for unsetting on the PHP-side.

# File lib/php_process.rb, line 413
def initialize(args)
  @args = args
  @args[:php].object_ids[self.__id__] = @args[:id]
  
  #Define finalizer so we can remove the object on PHPs side, when it is collected on the Ruby-side.
  ObjectSpace.define_finalizer(self, @args[:php].method(:objects_unsetter))
end

Public Instance Methods

__get_var(name) click to toggle source

Returns an instance-variable by name.

Examples

proxy_obj = php.new("stdClass")
proxy_obj.__set_var("testvar", 5)
proxy_obj.__get_var("testvar") #=> 5
# File lib/php_process.rb, line 443
def __get_var(name)
  return @args[:php].send(:type => "get_var", :id => @args[:id], :name => name)
end
__phpclass() click to toggle source

Returns the PHP-class of the object that this object refers to as a symbol.

Examples

proxy_obj.__phpclass #=> :PHPExcel
# File lib/php_process.rb, line 424
def __phpclass
  return @args[:php].func("get_class", self)
end
__set_var(name, val) click to toggle source

Sets an instance-variable on the object.

Examples

proxy_obj = php.new("stdClass")
proxy_obj.__set_var("testvar", 5)
proxy_obj.__get_var("testvar") #=> 5
# File lib/php_process.rb, line 433
def __set_var(name, val)
  @args[:php].send(:type => "set_var", :id => @args[:id], :name => name, :val => val)
  return nil
end
method_missing(method_name, *args) click to toggle source

Uses ‘method_missing’ to proxy all other calls onto the PHP-process and the PHP-object. Then returns the parsed result.

# File lib/php_process.rb, line 448
def method_missing(method_name, *args)
  return @args[:php].send(:type => :object_call, :method => method_name, :args => @args[:php].parse_data(args), :id => @args[:id])
end