def convert_to_hash(object)
      if !object.respond_to?(:to_hash)
        return nil
      end

      if object.method(:to_hash).arity != 0
        return nil
      end

      hash = object.to_hash
      if !hash.respond_to?(:keys) || !hash.respond_to?('[]')
        return nil
      end

      return hash
    end
def convert_to_hash(object)
      if !object.respond_to?(:to_hash)
        return nil
      end

      if object.method(:to_hash).arity != 0
        return nil
      end

      hash = object.to_hash
      if !hash.respond_to?(:keys) || !hash.respond_to?('[]')
        return nil
      end

      return hash
    end
Utility methods.
------------------------------------------------------------------------------