Skip to content

Instantly share code, notes, and snippets.

@radar
Created November 8, 2016 22:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radar/31038528f6b5997b8494caecf23b6220 to your computer and use it in GitHub Desktop.
Save radar/31038528f6b5997b8494caecf23b6220 to your computer and use it in GitHub Desktop.
defmodule Transaction do
defstruct [:merchant_id, :financial_context_id]
end
defmodule Transactions do
def process do
transactions = [
%Transaction{merchant_id: "12345", financial_context_id: "1234"},
%Transaction{merchant_id: "12345", financial_context_id: "1234"},
%Transaction{merchant_id: "12345", financial_context_id: "1234"},
%Transaction{merchant_id: "12345", financial_context_id: "1234"}
]
%{
merchant_ids: transactions |> Enum.map(&(&1.merchant_id)),
financial_context_id: transactions |> Enum.map(&(&1.financial_context_id)),
page_ids: transactions |> Enum.map(&get_page_id/1)
}
end
def get_page_id(_transaction) do
1
end
end
Transactions.process |> IO.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment