Extract rule generation into mixin