Clean up RestAdapter, add RestClass and RestMethod

Simplify the code building up the REST handler. Code that can be reused
is 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.).