Use respond_to? instead of rescue NoMethodError to avoid swallowing unrelated exceptions when sending a block.
Defining respond_to_missing?
Added to_hash and to_h to revert a shash back to a regular hash.