Handle resolving rule.as and rule.by.

As can be used to force different type. By can be factory for custom
resolving.