Clean up RestAdapter, add RestClass and RestMethod

Simplify the code building up the REST handler. Bits that can be reused
are moved to two new classes - RestAdapter and RestMethod.

These two new classes should contain all information needed to generate
front-end code (Angular $resource factory, Swagger descriptors, etc.).