private static void DefineAccessor(RubyScope/*!*/ scope, RubyModule/*!*/ self, string/*!*/ name, bool readable, bool writable) {
// MRI: ignores ModuleFunction scope flag (doesn't create singleton methods):
if (!Tokenizer.IsVariableName(name)) {
throw RubyExceptions.CreateNameError("invalid attribute name `{0}'", name);
}
var varName = "@" + name;
var attributesScope = scope.GetMethodAttributesDefinitionScope();
if (readable) {
var flags = (RubyMemberFlags)RubyUtils.GetSpecialMethodVisibility(attributesScope.Visibility, name);
self.AddMethod(scope.RubyContext, name, new RubyAttributeReaderInfo(flags, self, varName));
}
if (writable) {
self.AddMethod(scope.RubyContext, name + "=", new RubyAttributeWriterInfo((RubyMemberFlags)attributesScope.Visibility, self, varName));
}
}