Method: Rjb::JavaObjectWrapper.wrap_java_object

Defined in:
lib/ivy/java/java_object_wrapper.rb

.wrap_java_object(object) ⇒ Object

Convert a value returned by a call to the underlying Java object to the appropriate Ruby object.

If the value is a JavaObjectWrapper, convert it using a protected function with the name wrap_ followed by the underlying object’s classname with the Java path delimiters converted to underscores. For example, a java.util.ArrayList would be converted by a function called wrap_java_util_ArrayList.

If the value lacks the appropriate converter function, wrap it in a generic JavaObjectWrapper.

If the value is not a JavaObjectWrapper, return it unchanged.

This function is called recursively for every element in an Array.



79
80
81
82
83
84
85
86
87
88
# File 'lib/ivy/java/java_object_wrapper.rb', line 79

def wrap_java_object(object)
  if object.kind_of?(Array)
    object.collect {|item| wrap_java_object(item)}
  elsif object.respond_to?(:_classname)
    # Ruby-Java Bridge Java objects all have a _classname member
    find_converter(object) || JavaObjectWrapper.new(object)
  else
    object
  end
end