It was a question to ‘learn’ where was the DCI because I’ve never used it in Rails (only in Java).
Not much criteria about if this is a good practice or not.

From: Yann Marquet Yann Marquet
Reply: moneyadviceservice/frontend reply@reply.github.com
Date: 13 de febrero de 2014 at 08:42:28
To: moneyadviceservice/frontend frontend@noreply.github.com
Subject:  Re: [frontend] API repository backed by Faraday (#58)  
In lib/core/repositories/api.rb:

> +          faraday.response :raise_error
> +          faraday.response :json
> +
> +          faraday.use :instrumentation
> +          faraday.adapter Faraday.default_adapter
> +        end
> +      end
> +
> +      def find(id)
> +        response = connection.get("/%{locale}/%{type}/%{id}.json" %
> +                                    { locale: I18n.locale, type: type.pluralize, id: id })
> +        response.body
> +      rescue Faraday::Error::ResourceNotFound
> +        nil
> +      rescue Faraday::Error::ConnectionFailed, Faraday::Error::ClientError => e
> +        raise e.extend(RequestError)
@pmanrubia Whether this is a DCI pattern or not might be arguable but as you can see here, using Object#extendat runtime, busts the method cache and this is why it is not a recommended practice.

—
Reply to this email directly or view it on GitHub.