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

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

本文整理了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

  1. /**
  2. * Define a new module under the Object namespace. Roughly equivalent to
  3. * rb_define_module in MRI.
  4. *
  5. * @param name The name of the new module
  6. * @returns The new module
  7. */
  8. @Extension
  9. public RubyModule defineModule(String name) {
  10. return defineModuleUnder(name, objectClass);
  11. }

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

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

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

  1. /**
  2. * Define a new module under the Object namespace. Roughly equivalent to
  3. * rb_define_module in MRI.
  4. *
  5. * @param name The name of the new module
  6. * @returns The new module
  7. */
  8. @Extension
  9. public RubyModule defineModule(String name) {
  10. return defineModuleUnder(name, objectClass);
  11. }

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

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

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

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

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

  1. /**
  2. * Define a new module under the Object namespace. Roughly equivalent to
  3. * rb_define_module in MRI.
  4. *
  5. * @param name The name of the new module
  6. * @returns The new module
  7. */
  8. @Extension
  9. public RubyModule defineModule(String name) {
  10. return defineModuleUnder(name, objectClass);
  11. }

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

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

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

  1. /**
  2. * Define a new module under the Object namespace. Roughly equivalent to
  3. * rb_define_module in MRI.
  4. *
  5. * @param name The name of the new module
  6. * @returns The new module
  7. */
  8. @Extension
  9. public RubyModule defineModule(String name) {
  10. return defineModuleUnder(name, objectClass);
  11. }

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

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

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

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

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

  1. public static RubyClass getRackInputClass(final Ruby runtime) { // JRuby::Rack::Input
  2. RubyModule jruby = runtime.getOrCreateModule("JRuby");
  3. RubyModule rack = (RubyModule) jruby.getConstantAt("Rack");
  4. if (rack == null) {
  5. rack = runtime.defineModuleUnder("Rack", jruby);
  6. }
  7. RubyClass klass = rack.getClass("Input"); // JRuby::Rack getClass('Input')
  8. if (klass == null) {
  9. final RubyClass parent = runtime.getObject();
  10. klass = rack.defineClassUnder("Input", parent, ALLOCATOR);
  11. klass.defineAnnotatedMethods(RackInput.class);
  12. }
  13. if (jruby.getConstantAt("RackInput") == null) { // backwards compatibility
  14. jruby.setConstant("RackInput", klass); // JRuby::RackInput #deprecated
  15. }
  16. return klass;
  17. }

相关文章

Ruby类方法