/** set_method_visibility * */ public void setMethodVisibility(IRubyObject[] methods, Visibility visibility) { for (int i = 0; i < methods.length; i++) { exportMethod(TypeConverter.checkID(methods[i]).idString(), visibility); } }
/** set_method_visibility * */ public void setMethodVisibility(IRubyObject[] methods, Visibility visibility) { for (int i = 0; i < methods.length; i++) { exportMethod(TypeConverter.checkID(methods[i]).idString(), visibility); } }
/** rb_mod_attr_writer * */ @JRubyMethod(name = "attr_writer", rest = true, reads = VISIBILITY) public IRubyObject attr_writer(ThreadContext context, IRubyObject[] args) { // Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed Visibility visibility = context.getCurrentVisibility(); for (int i = 0; i < args.length; i++) { addAccessor(context, TypeConverter.checkID(args[i]), visibility, false, true); } return context.nil; }
/** rb_mod_attr_reader * */ @JRubyMethod(name = "attr_reader", rest = true, reads = VISIBILITY) public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args) { // Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed Visibility visibility = context.getCurrentVisibility(); for (int i = 0; i < args.length; i++) { addAccessor(context, TypeConverter.checkID(args[i]), visibility, true, false); } return context.nil; }
@JRubyMethod(name = "undef_method", rest = true) public RubyModule undef_method(ThreadContext context, IRubyObject[] args) { for (int i=0; i<args.length; i++) { RubySymbol name = TypeConverter.checkID(args[i]); undef(context, name.idString()); } return this; }
/** rb_mod_attr_reader * */ @JRubyMethod(name = "attr_reader", rest = true, reads = VISIBILITY) public IRubyObject attr_reader(ThreadContext context, IRubyObject[] args) { // Check the visibility of the previous frame, which will be the frame in which the class is being eval'ed Visibility visibility = context.getCurrentVisibility(); for (int i = 0; i < args.length; i++) { addAccessor(context, TypeConverter.checkID(args[i]), visibility, true, false); } return context.nil; }
@JRubyMethod(name = "remove_method", rest = true) public RubyModule remove_method(ThreadContext context, IRubyObject[] args) { for(int i=0;i<args.length;i++) { removeMethod(context, TypeConverter.checkID(args[i]).idString()); } return this; }
@JRubyMethod(name = "remove_method", rest = true) public RubyModule remove_method(ThreadContext context, IRubyObject[] args) { for(int i=0;i<args.length;i++) { removeMethod(context, TypeConverter.checkID(args[i]).idString()); } return this; }
@JRubyMethod(name = "undef_method", rest = true) public RubyModule undef_method(ThreadContext context, IRubyObject[] args) { for (int i=0; i<args.length; i++) { RubySymbol name = TypeConverter.checkID(args[i]); undef(context, name.idString()); } return this; }
@JRubyMethod(name = "instance_method", required = 1) public IRubyObject instance_method(IRubyObject symbol) { return newMethod(null, TypeConverter.checkID(symbol).idString(), false, null); }
@JRubyMethod(name = "alias_method", required = 2) public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyObject oldId) { RubySymbol newSym = TypeConverter.checkID(newId); RubySymbol oldSym = TypeConverter.checkID(oldId); // MRI uses rb_to_id but we return existing symbol defineAlias(newSym.idString(), oldSym.idString()); if (isSingleton()) { ((MetaClass) this).getAttached().callMethod(context, "singleton_method_added", newSym); } else { callMethod(context, "method_added", newSym); } return this; }
@JRubyMethod(name = "alias_method", required = 2) public RubyModule alias_method(ThreadContext context, IRubyObject newId, IRubyObject oldId) { RubySymbol newSym = TypeConverter.checkID(newId); RubySymbol oldSym = TypeConverter.checkID(oldId); // MRI uses rb_to_id but we return existing symbol defineAlias(newSym.idString(), oldSym.idString()); if (isSingleton()) { ((MetaClass) this).getAttached().callMethod(context, "singleton_method_added", newSym); } else { callMethod(context, "method_added", newSym); } return this; }
@JRubyMethod(name = "private_method_defined?", required = 1) public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE); }
@JRubyMethod(name = "protected_method_defined?", required = 1) public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED); }
protected String validateClassVariable(Ruby runtime, IRubyObject object) { RubySymbol name = TypeConverter.checkID(object); if (!name.validClassVariableName()) { throw getRuntime().newNameError(str(runtime, "`", ids(runtime, name), "' is not allowed as a class variable name"), this, object); } return name.idString(); }
@JRubyMethod(name = "public_method_defined?", required = 1) public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC); }
@JRubyMethod(name = "public_method_defined?", required = 1) public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC); }
protected String validateClassVariable(Ruby runtime, IRubyObject object) { RubySymbol name = TypeConverter.checkID(object); if (!name.validClassVariableName()) { throw getRuntime().newNameError(str(runtime, "`", ids(runtime, name), "' is not allowed as a class variable name"), this, object); } return name.idString(); }
@JRubyMethod(name = "protected_method_defined?", required = 1) public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED); }
@JRubyMethod(name = "private_method_defined?", required = 1) public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) { DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString()); return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE); }