Issue #4537 has been updated by bug hit.


why should top level visibility (which applies to methods defined in the Object class) have any effect on other classes?

this also applies to any other module which you might be in

```ruby
class Class1
end

module SomeUnrelatedModule
  Class1.send(:attr_accessor, :public_attr)
  private
  Class1.send(:attr_accessor, :private_attr)
end

c1 = Class1.new
c1.public_attr
c1.private_attr
```

what does visibility in SomeUnrelatedModule have to do with methods defined in Class1?

methods defined on a given target module when the default definee at the point of definition is not the target module, should be public, since that's the default visibility

```ruby
Class1.send(:define_method,  :foo) {}
```

defines a public method

```ruby
Class1.send(:attr_accessor, :foo)
```

should too


----------------------------------------
Bug #4537: Incorrectly creating private method via attr_accessor
https://bugs.ruby-lang.org/issues/4537#change-60250

* Author: Ryan LeCompte
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30907) [x86_64-darwin10.7.0]
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
# The following fails with a failure to call "x=" private method
String.send(:attr_accessor, :x)
s = ""
s.x = 100

# The following works:
class String
  self.send(:attr_accessor, :x)
end
s = ""
s.x = 100



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>