-
-
Save alco/6353899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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