This is a lot of logic to embed in a DSL method, which suggest to me that there should be some intermediate object that collects these things.