The idea of โโmutability is not really applied in Ruby in the same way as in other languages. The only immutable object is frozen. You can even add instance methods and variables to Fixnums. For instance:
class Fixnum attr_accessor :name end 1.name = "one" 2.name = "two"
Obviously, the vast majority of the time, people will not be pathological enough to add attributes to Fixnum, but the fact is that an unfrozen object is truly unchanged.
If you can come up with a canonical list of classes that you want to accept, they are immutable, you can just go through and give them all the immutable?() Method, which returns true (and Object a version, which returns false). But, as wvanbergen said, the best way to make sure your copy of an object is not changing is to copy it deeply with the marshal.
Chuck source share