Skip to content

Instantly share code, notes, and snippets.

@danielberkompas
danielberkompas / destructure.ex
Created October 31, 2016 20:26
Javascript-style Destructuring for Elixir
defmodule Destructure do
@moduledoc """
Provides helpers for destructuring Elixir data structures. See the `d/1` macro
for more information.
"""
@doc """
Easy destructuring of maps and keyword lists, with atom keys only.
## Examples
@danielberkompas
danielberkompas / auth.ex
Created March 4, 2017 20:44
An example of how to hack together Ueberauth.Auth structs
defmodule MyApp.Auth do
@moduledoc """
Creates `Ueberauth.Auth` structs from OAuth responses.
This module is an ugly hack which is necessary because `Ueberauth` doesn't provide
the necessary hooks to get such a struct without giving it control of the whole
callback phase. We can't do this in the API because all the mobile app can give us
is the OAuth token.
Most of the code was lifted from Ueberauth, with minor changes as needed.