@Override public String getName() { return origin.getName(); }
@JRubyMethod(name = "inspect") @Override public IRubyObject inspect() { RubyModule rubyClass = getMetaClass(); StringBuilder buffer = new StringBuilder("#<"); buffer.append(rubyClass.getName()).append(": ").append(success.inspect().toString()); buffer.append(", ").append(failed.inspect().toString()).append(">"); return getRuntime().newString(buffer.toString()); } }
public final void setConstantVisibility(Ruby runtime, String name, boolean hidden) { ConstantEntry entry = getConstantMap().get(name); if (entry == null) { throw runtime.newNameError("constant " + getName() + "::" + name + " not defined", name); } storeConstant(name, entry.value, hidden); }
public final void setConstantVisibility(Ruby runtime, String name, boolean hidden) { ConstantEntry entry = getConstantMap().get(name); if (entry == null) { throw runtime.newNameError("constant " + getName() + "::" + name + " not defined", name); } storeConstant(name, entry.value, hidden); }
private void setConstantVisibility(ThreadContext context, String name, boolean hidden) { ConstantEntry entry = getConstantMap().get(name); if (entry == null) { throw context.runtime.newNameError("constant " + getName() + "::" + name + " not defined", name); } getConstantMapForWrite().put(name, new ConstantEntry(entry.value, hidden)); }
private void setConstantVisibility(ThreadContext context, String name, boolean hidden) { ConstantEntry entry = getConstantMap().get(name); if (entry == null) { throw context.runtime.newNameError("constant " + getName() + "::" + name + " not defined", name); } getConstantMapForWrite().put(name, new ConstantEntry(entry.value, hidden)); }
private static String formatReceiver(final IRubyObject object) { if ( object instanceof RubyModule ) { return ((RubyModule) object).getName(); } return object.getMetaClass().getRealClass().getName(); }
private static String formatReceiver(final IRubyObject object) { if ( object instanceof RubyModule ) { return ((RubyModule) object).getName(); } return object.getMetaClass().getRealClass().getName(); }
public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException { if (!this.hasModuleInHierarchy(originModule)) { if (originModule instanceof MetaClass) { throw context.runtime.newTypeError("can't bind singleton method to a different class"); } else { throw context.runtime.newTypeError("bind argument must be an instance of " + originModule.getName()); } } }
public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException { // Module methods can always be transplanted if (!originModule.isModule() && !hasModuleInHierarchy(originModule)) { if (originModule instanceof MetaClass) { throw context.runtime.newTypeError("can't bind singleton method to a different class"); } else { throw context.runtime.newTypeError("bind argument must be an instance of " + originModule.getName()); } } }
public IRubyObject fetchConstant(String name, boolean includePrivate) { assert IdUtil.isConstant(name); ConstantEntry entry = constantEntryFetch(name); if (entry == null) return null; if (entry.hidden && !includePrivate) { throw getRuntime().newNameError("private constant " + getName() + "::" + name + " referenced", name); } return entry.value; }
public void checkValidBindTargetFrom(ThreadContext context, RubyModule originModule) throws RaiseException { // Module methods can always be transplanted if (!originModule.isModule() && !hasModuleInHierarchy(originModule)) { if (originModule instanceof MetaClass) { throw context.runtime.newTypeError("can't bind singleton method to a different class"); } else { throw context.runtime.newTypeError("bind argument must be an instance of " + originModule.getName()); } } }
private void checkAndRaiseIfFrozen() throws RaiseException { if ( isFrozen() ) { if (this instanceof RubyClass) { if (getBaseName() == null) { // anonymous // MRI 2.2.2 does get ugly ... as it skips this logic : // RuntimeError: can't modify frozen #<Class:#<Class:0x0000000095a920>> throw getRuntime().newFrozenError(getName()); } throw getRuntime().newFrozenError("#<Class:" + getName() + '>'); } throw getRuntime().newFrozenError("Module"); } }
@JRubyMethod(name = "name") public IRubyObject name() { Ruby runtime = getRuntime(); if (getBaseName() == null) { return RubyString.newEmptyString(runtime); } else { return runtime.newString(getName()); } }
public IRubyObject removeClassVariable(String name) { String javaName = validateClassVariable(name); IRubyObject value; if ((value = deleteClassVariable(javaName)) != null) { return value; } if (isClassVarDefined(javaName)) { throw cannotRemoveError(javaName); } throw getRuntime().newNameError("class variable " + javaName + " not defined for " + getName(), javaName); }
public IRubyObject removeClassVariable(String name) { String javaName = validateClassVariable(name); IRubyObject value; if ((value = deleteClassVariable(javaName)) != null) { return value; } if (isClassVarDefined(javaName)) { throw cannotRemoveError(javaName); } throw getRuntime().newNameError("class variable " + javaName + " not defined for " + getName(), javaName); }
public IRubyObject removeClassVariable(String name) { String javaName = validateClassVariable(name); IRubyObject value; if ((value = deleteClassVariable(javaName)) != null) { return value; } if (isClassVarDefined(javaName)) { throw cannotRemoveError(javaName); } throw getRuntime().newNameError("class variable " + javaName + " not defined for " + getName(), javaName); }
public IRubyObject removeClassVariable(String name) { String javaName = validateClassVariable(name); IRubyObject value; if ((value = deleteClassVariable(javaName)) != null) { return value; } if (isClassVarDefined(javaName)) { throw cannotRemoveError(javaName); } throw getRuntime().newNameError("class variable " + javaName + " not defined for " + getName(), javaName); }