Skip to main content

README.md

![Octopus](https://github.com/janpieper/octopus/blob/master/octopus.png "Octopus")

# Octopus

## Examples

```
user_id = current_user_id(conn)

results = Matchday.get_results(user_id: user_id)

render(conn, "foo.json", %{results: results})
```


```
assigns =
  conn
  |> current_user_id()
  |> Octopus.map(& [user_id: &1])                # 1
  |> Backend.Matchday.get_results_for_user()
  |> Octopus.map(& %{user_matchday_results: &1}) # 2

render(conn, "foo.json", assigns)
```

1. Maps `12345` to `[user_id: 12345]`
2. Maps `[123, 456, 789]` to `%{results: [123, 456, 789]}`