Gavin Kistner
3/22/2007 4:21:00 PM
On Mar 22, 2:53 am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
> | 3/ The naming of these methods are quite confusing. Each time I read them I understand "give me the private/public class method ...". The naming is too/very close to private_methods, public_methods, ...
> | I would prefer something like class_private, class_protected, class_public.
>
> What do you confuse with what? For me, class_private etc. mean nothing.
If I may attempt to be an interpreter, I think what the OP was saying
was if you look at this list...
# Return a method by name
Module#method
Module#instance_method
# Return array of method names
Module#methods
Module#singleton_methods
Module#instance_methods
Module#private_methods
Module#private_instance_methods
Module#protected_methods
Module#protected_instance_methods
Module#public_methods
Module#public_instance_methods
# Change method 'scope'
Module#private_class_method
Module#public_class_method
....you see that most methods with "method" in their name return
something about methods, but the last two cause a change to the method
'scope'. I can see the confusion in particular between the first two
and the last two:
Klass.method( :foo ) #=> find a method
Klass.public_class_method( :foo ) #=> change scope
Klass.instance_method( :foo ) #=> find a method
The other question of the OP was "I know about three scopes in Ruby:
'public', 'protected', and 'private'. However, I only see
#public_class_method and #private_class_method. For consistency,
shouldn't there also be #protected_class_method."