include Singleton : Singletons « Design Patterns « Ruby






include Singleton


require 'singleton'

class Manager
  include Singleton

  def manage_resources
    puts("I am managing my resources")
  end
end

m = Manager.new

 








Related examples in the same category

1.define class methods by using a class within a class's singleton class like the code
2.Define a singleton method, one that is tied to a single object
3.Singleton a class
4.Classes as Singletons
5.Modules as Singletons