Search code examples
rubyautocompletesingletoncontent-assist

ruby instance has no content assist (or autocomplete) with singleton pattern


Below is a class with singleton pattern applied. But its instance has no content assist any more.

require 'singleton'
class Tst_case1
  include Singleton
  def sayHello
    puts "hello"
  end
end
case1 = Tst_case1.instance
case1. #there should be a popover listing the available methods, but no.

I test this on NetBeans 6.9.1 and Squish (an IDE based on eclipse), Both has not content assist. I think this is not IDE's issue, should be ruby's issue.

Is there any way to make the content assist work with the singleton pattern? It's hard to write code with no content assist.

Thanks in advance


Solution

  • Figure out a workaround by not using the singleton lib. Write the singleton self.instanc method inside the class.