Maybe this will work:
class Project
class << self; attr_accessor :instances; end
attr_accessor :name, :tasks
def initialize(options)
@name = options[:name]
@tasks = options[:tasks]
self.class.instances ||= Array.new
self.class.instances << self
end
def self.all
# return listing of project objects
instances ? instances.dup : []
end
def self.count
# return a count of existing projects
instances ? instances.count : 0
end
def destroy
self.class.instances.delete(self)
end
end
But you will have to manually destroy these objects. Maybe other solution can be build based on ObjectSpace module.