Changing record fields

I have a set of records (def) in a .td file which are all of Op derived class type. What I want to do is change their extraClassDeclaration fields based on some condition depending on the traits they were defined with. E.g.:

def SomeOp : Op<Dialect, "SomeOp", [DeclareOpInterfaceMethods<InferTypeOpInterface>];
def SomeOtherOp : Op<Dialect, "SomeOtherOp", [];

I’d like to iterate over all these records and set extraClassDeclaration field to some value if the record has trait DeclareOpInterfaceMethods.
How to do this?