Skip to content

Instantly share code, notes, and snippets.

@alco
Forked from chrismccord/gist:6349128
Last active December 21, 2015 19:20
Show Gist options
  • Save alco/6353899 to your computer and use it in GitHub Desktop.
Save alco/6353899 to your computer and use it in GitHub Desktop.
defrecord User, email: nil
defimpl Access, for: User do
def access(record, attr) do
index = record.__record__(:index, attr)
elem(record, index)
end
end
user = User.new(email: "[email protected]")
iex> user[:email]
"[email protected]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment