which actually reminds me of another question I had - is there a global scope accessible somewhere? It would be very handy for declaring constants (val). I’ve noticed I cannot access Items in the rule file scope (ie variables declared at the top of the file - not within the rule scope).
To answer your specific questions, the answer is no. You cannot create your own classes and use them in Rules DSL. There is no global context somewhere. Well, that last part isn’t strictly true. You do have access to a global context: Items.
Depending on the nature of your repeated code, there are a many techniques that can be used to avoid that.
I’m tired of retyping this so I wrote a DP: Design Pattern: DRY, How Not to Repeat Yourself in Rules DSL. It’s more of a meta-DP since everything is already documented in DPs and tutorials but people are either not finding them or not looking for them.