About singleton_methods

class A
  class << A
    def aaa
    end

    protected
    def bbb
    end

    private
    def ccc
    end
  end
end

p A.singleton_methods # => ["aaa", "bbb"]

# private method is not a singleton method.. Why?
# Anyway 'ccc' is defined in a singleton class of A ?

···

###############
# Help Me^^
###############
--
Posted via http://www.ruby-forum.com/.

I have never noticed that before, I certainly do not like that.

If you need that information you could do the following

class Object
  def my_sing_methods # this does not sing
    singleton_methods + begin
   class << self; self end.private_instance_methods( false )
      rescue
        
    end
  end
end

This however gives you three more methods, namely :inherited,
:initialize, :initialize_copy.
You can of course get rid of them, but what if they are overloaded?
Unfortunately I can not
think of any simple code to cover that.

Cheers
Robert

···

On Thu, Jan 8, 2009 at 8:29 AM, Kyung won Cheon <kdream95@gmerce.co.kr> wrote:

class A
class << A
   def aaa
   end

   protected
   def bbb
   end

   private
   def ccc
   end
end
end

p A.singleton_methods # => ["aaa", "bbb"]

# private method is not a singleton method.. Why?
# Anyway 'ccc' is defined in a singleton class of A ?

###############
# Help Me^^
###############
--
Posted via http://www.ruby-forum.com/\.

--
It is change, continuing change, inevitable change, that is the
dominant factor in society today. No sensible decision can be made any
longer without taking into account not only the world as it is, but
the world as it will be ... ~ Isaac Asimov