defmodule Bwc.TestRepo do
  alias Bwc.Card

  @cards [
    %Card{id: 0, title: "Baby's First Card", picture: "0.jpg", description: "This card does nothing."},    
    %Card{id: 0, title: "YUGE", picture: "1.jpg", description: ""},    
    %Card{id: 0, title: "Test Card", picture: "2.jpg", description: "Angelica approves."}    
    ]

  def all(Card), do: @cards

  def get!(Card, id), do: Enum.find(@cards,fn(card) -> card.id == id end)

  def get_by(Card, attrs) do
    Enum.find(@cards, fn(card) ->

      Enum.all?(Map.keys(attrs), fn(key) ->
	Map.get(card,key) == attrs[key]
	end)          
      end)    
  end

end
