org.jruby.Ruby.defineModuleUnder()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.jruby.Ruby.defineModuleUnder方法的一些代码示例,展示了Ruby.defineModuleUnder的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.defineModuleUnder方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:defineModuleUnder

Ruby.defineModuleUnder介绍

[英]Define a new module with the given name under the given module or class namespace. Roughly equivalent to rb_define_module_under in MRI.
[中]在给定的模块或类名称空间下定义具有给定名称的新模块。大致相当于MRI中的rb_define_module_。

代码示例

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** 
 * Define a new module under the Object namespace. Roughly equivalent to
 * rb_define_module in MRI.
 * 
 * @param name The name of the new module
 * @returns The new module
 */
@Extension
public RubyModule defineModule(String name) {
  return defineModuleUnder(name, objectClass);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** rb_define_module_under
 *  this method should be used only as an API to define/open nested module
 */
public RubyModule defineModuleUnder(String name) {
  return getRuntime().defineModuleUnder(name, this);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Define a new module under the Object namespace. Roughly equivalent to
 * rb_define_module in MRI.
 *
 * @param name The name of the new module
 * @returns The new module
 */
@Extension
public RubyModule defineModule(String name) {
  return defineModuleUnder(name, objectClass);
}

代码示例来源:origin: org.jruby/jruby-complete

/** rb_define_module_under
 *  this method should be used only as an API to define/open nested module
 */
public RubyModule defineModuleUnder(String name) {
  return getRuntime().defineModuleUnder(name, this);
}

代码示例来源:origin: org.jruby/jruby-core

/** rb_define_module_under
 *  this method should be used only as an API to define/open nested module
 */
public RubyModule defineModuleUnder(String name) {
  return getRuntime().defineModuleUnder(name, this);
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Define a new module under the Object namespace. Roughly equivalent to
 * rb_define_module in MRI.
 *
 * @param name The name of the new module
 * @returns The new module
 */
@Extension
public RubyModule defineModule(String name) {
  return defineModuleUnder(name, objectClass);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** rb_define_module_under
 *  this method should be used only as an API to define/open nested module
 */
public RubyModule defineModuleUnder(String name) {
  return getRuntime().defineModuleUnder(name, this);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** 
 * Define a new module under the Object namespace. Roughly equivalent to
 * rb_define_module in MRI.
 * 
 * @param name The name of the new module
 * @returns The new module
 */
@Extension
public RubyModule defineModule(String name) {
  return defineModuleUnder(name, objectClass);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static void initPsychToRuby(Ruby runtime, RubyModule psych) {
  RubyModule visitors = runtime.defineModuleUnder("Visitors", psych);
  RubyClass visitor = runtime.defineClassUnder("Visitor", runtime.getObject(), runtime.getObject().getAllocator(), visitors);
  RubyClass psychToRuby = runtime.defineClassUnder("ToRuby", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
  psychToRuby.defineAnnotatedMethods(PsychToRuby.class);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static void initPsychToRuby(Ruby runtime, RubyModule psych) {
  RubyModule visitors = runtime.defineModuleUnder("Visitors", psych);
  RubyClass visitor = runtime.defineClassUnder("Visitor", runtime.getObject(), runtime.getObject().getAllocator(), visitors);
  RubyClass psychToRuby = runtime.defineClassUnder("ToRuby", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
  psychToRuby.defineAnnotatedMethods(PsychToRuby.class);
}

代码示例来源:origin: org.jruby.rack/jruby-rack

public static RubyClass getRackInputClass(final Ruby runtime) { // JRuby::Rack::Input
  
  RubyModule jruby = runtime.getOrCreateModule("JRuby");
  RubyModule rack = (RubyModule) jruby.getConstantAt("Rack");
  if (rack == null) {
    rack = runtime.defineModuleUnder("Rack", jruby);
  }
  RubyClass klass = rack.getClass("Input"); // JRuby::Rack getClass('Input')
  if (klass == null) {
    final RubyClass parent = runtime.getObject();
    klass = rack.defineClassUnder("Input", parent, ALLOCATOR);
    klass.defineAnnotatedMethods(RackInput.class);
  }
  
  if (jruby.getConstantAt("RackInput") == null) { // backwards compatibility
    jruby.setConstant("RackInput", klass); // JRuby::RackInput #deprecated
  }
  
  return klass;
}

相关文章

Ruby类方法