Add "withTraits" method to dynamically implement traits