Extract attribute handling in a trait.