本文整理了Java中org.jruby.RubyModule.setAutoloadConstant
方法的一些代码示例,展示了RubyModule.setAutoloadConstant
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.setAutoloadConstant
方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称: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) {
内容来源于网络,如有侵权,请联系作者删除!