I assume this is caused by r40022, which made define_method consider visibility. However, visibility should only be considered if define_method is called normally, not via send. When called via send, it should define a public method. Here's example code showing the error:
$ ruby21 -ve "Object.send(:define_method, :foo){|*a| 1}.foo"
-e:1:in <main>': private method foo' called for :foo:Symbol (NoMethodError)
I apologize in advance if this has already been fixed (I tested 2.1.0-preview1, not trunk), but from the commit logs it doesn't appear to have been.
There's only two days until the release of 2.1.0, and this still hasn't been fixed. This is a serious regression that breaks existing code (among other things, it causes Sequel's tests to freeze). If this can't be fixed before 2.1.0, I think r40022 should be reverted on the 2.1 branch, and the feature should be moved to 2.2.0. Assuming this is fixed on trunk before 2.1.0, it should be immediately backported to the 2.1 branch.
This issue was solved with changeset r44380.
Jeremy, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
proc.c: make method by define_method public
proc.c (rb_mod_define_method): consider visibility only if self
in the caller is same as the receiver, otherwise make public as
well as old behavior. [ruby-core:57747] [Bug #9005] [ruby-core:58497] [Bug #9141]
vm.c (rb_vm_cref_in_context): return ruby level cref if self is
same.
The behavior change here is deliberate, since you are calling define_method inside the class definition after calling private. This bug was that define_method when called outside the class definition was generating private methods, which was fixed before the release of 2.1.0.