Java Code Examples for org.jruby.Ruby#getCurrentContext()
The following examples show how to use
org.jruby.Ruby#getCurrentContext() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * instantiateClass * * @param runtime * @param name * @param args * @return */ public static IRubyObject instantiateClass(Ruby runtime, String name, IRubyObject... args) { ThreadContext threadContext = runtime.getCurrentContext(); IRubyObject result = null; // try to load the class RubyClass rubyClass = runtime.getClass(name); // instantiate it, if it exists if (rubyClass != null) { result = rubyClass.newInstance(threadContext, args, Block.NULL_BLOCK); } return result; }
Example 2
Source File: ScriptUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * instantiateClass * * @param runtime * @param module * @param name * @param args * @return */ public static IRubyObject instantiateClass(Ruby runtime, String module, String name, IRubyObject... args) { ThreadContext threadContext = runtime.getCurrentContext(); IRubyObject result = null; // try to load the module RubyModule rubyModule = runtime.getModule(module); if (rubyModule != null) { // now try to load the class RubyClass rubyClass = rubyModule.getClass(name); // instantiate it, if it exists if (rubyClass != null) { result = rubyClass.newInstance(threadContext, args, Block.NULL_BLOCK); } } return result; }