Repository pattern with Ruby on Rails: Decoupling ActiveRecord and persistence layer

Intro

The Repository pattern is a way of working with a data source. In the book Patterns of Enterprise Application Architecture, Martin Fowler describes a repository as follows: