Call encode on object not from class