Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Last active December 22, 2015 23:19
Show Gist options
  • Save davidcelis/6545514 to your computer and use it in GitHub Desktop.
Save davidcelis/6545514 to your computer and use it in GitHub Desktop.
Update every instance of a Ruby class
class Worker
class << self
attr_accessor :instances
def update_instances
instances.each do |instance|
# Update accordingly
end
end
end
def initialize
self.class.instances ||= []
self.class.instances << self
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment