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
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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: "foo@bar.com")
iex> user[:email]
"foo@bar.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment