org.jruby.RubyModule.setAutoloadConstant()方法的使用及代码示例

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

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

RubyModule.setAutoloadConstant介绍

[英]Set an Object as a defined constant in autoloading.
[中]将对象设置为自动加载中定义的常量。

代码示例

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

/**
 * Set the named constant on this module. Also, if the value provided is another Module and
 * that module has not yet been named, assign it the specified name.
 *
 * @param name The name to assign
 * @param value The value to assign to it; if an unnamed Module, also set its basename to name
 * @return The result of setting the variable.
 */
private IRubyObject setConstantCommon(String name, IRubyObject value, boolean hidden, boolean warn) {
  IRubyObject oldValue = fetchConstant(name);
  setParentForModule(name, value);
  if (oldValue != null) {
    boolean notAutoload = oldValue != UNDEF;
    if (notAutoload || !setAutoloadConstant(name, value)) {
      if (warn && notAutoload) {
        getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + name);
      }
      // might just call storeConstant(name, value, hidden) but to maintain
      // backwards compatibility with calling #storeConstant overrides
      if (hidden) storeConstant(name, value, true);
      else storeConstant(name, value);
    }
  } else {
    if (hidden) storeConstant(name, value, true);
    else storeConstant(name, value);
  }
  invalidateConstantCache(name);
  return value;
}

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

/**
 * Set the named constant on this module. Also, if the value provided is another Module and
 * that module has not yet been named, assign it the specified name.
 *
 * @param name The name to assign
 * @param value The value to assign to it; if an unnamed Module, also set its basename to name
 * @return The result of setting the variable.
 */
private IRubyObject setConstantCommon(String name, IRubyObject value, boolean hidden, boolean warn) {
  IRubyObject oldValue = fetchConstant(name);
  setParentForModule(name, value);
  if (oldValue != null) {
    boolean notAutoload = oldValue != UNDEF;
    if (notAutoload || !setAutoloadConstant(name, value)) {
      if (warn && notAutoload) {
        getRuntime().getWarnings().warn(ID.CONSTANT_ALREADY_INITIALIZED, "already initialized constant " + name);
      }
      // might just call storeConstant(name, value, hidden) but to maintain
      // backwards compatibility with calling #storeConstant overrides
      if (hidden) storeConstant(name, value, true);
      else storeConstant(name, value);
    }
  } else {
    if (hidden) storeConstant(name, value, true);
    else storeConstant(name, value);
  }
  invalidateConstantCache(name);
  return value;
}

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

if (oldValue != null) {
  if (oldValue == UNDEF) {
    setAutoloadConstant(name, value);
  } else {
    if (warn) {

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

if (oldValue != null) {
  if (oldValue == UNDEF) {
    setAutoloadConstant(name, value);
  } else {
    if (warn) {

相关文章

微信公众号

最新文章

更多

RubyModule类方法