KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have written a custom Rails model. This model is backed by an actually server not by a database table (so it does not inherit from ActiveRecord::Base ). In order to get the requested information from the server I open a SSH connection to it. Because rails does not reuse object a new object, as well as a new SSH connection to the server, will be created for ever request that is received. To reduce server stress I want to close the SSH connection before the model object gets garbage collected. I am wondering does ruby provide a notification mechanism to inform the object that it will be destroyed? If so I could use this notification to know when to close the SSH connections. If not I will need to do it manual when I know I am finished with the object. If I need to manually take care of this, can I explicitly destroy the object? Or is the best i can do is object = nil ?
Tags (comma-separated)
Save Edits
Cancel