Extract base pipeline class

To implement agnostic pipeline gem we need a base class with basic API. This PR tries to do that.