title: Rewrite Programming Phoenix example function using pipes
body: <p>In Programming Phoenix, chapter 3, there is a hardcoded repo example with the following code:</p>
  
  <pre><code>defmodule Rumbl.Repo do
    @moduledoc """
    In memory repository.
    """
  
    def all(Rumbl.User) do
      [%Rumbl.User{id: "1", name: "José", username: "josevalim", password: "elixir"},
       %Rumbl.User{id: "2", name: "Bruce", username: "redrapids", password: "7langs"},
       %Rumbl.User{id: "3", name: "Chris", username: "chrismccord", password: "phx"}]
    end
  
    def all(_module), do: []
  
    def get(module, id) do
      Enum.find all(module), fn map -&gt; map.id == id end
    end
  
    def get_by(module, params) do
      Enum.find all(module), fn map -&gt;
        Enum.all?(params, fn {key, val} -&gt; Map.get(map, key) == val end)
      end
    end
  end
  </code></pre>
  
  <p>Using a pipe, I rewrote <code>get/2</code> in a way that seems easier to understand:</p>
  
  <pre>
    def get(module, id) do
      all(module)
      |> Enum.find fn map -> map.id == id end
    end
  </pre>
  
  <p>Is there a simple way to do the same to <code>get_by/2</code>?</p>