Add convenience methods for getting a struct from a ruby object.

If we are trying to get the struct from something other than self, then we
should make sure to check the class of the object.  This util functions
make this easier.