Created
April 9, 2012 13:40
-
-
Save bellthoven/2343470 to your computer and use it in GitHub Desktop.
Access orddict by strings
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
diff --git a/lib/access.ex b/lib/access.ex | |
index 009fdf2..1b3d396 100644 | |
--- a/lib/access.ex | |
+++ b/lib/access.ex | |
@@ -27,6 +27,10 @@ defimpl Access, for: List do | |
atom_access(list, atom) | |
end | |
+ def access(list, binary) when is_binary(binary) do | |
+ atom_access(list, binary_to_atom(binary)) | |
+ end | |
+ | |
## Regex | |
def access(list, re) when is_regex(re) do | |
@@ -78,4 +82,4 @@ defimpl Access, for: Function do | |
def access(function, item) do | |
function.(item) | |
end | |
-end | |
\ No newline at end of file | |
+end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment