Created
May 9, 2012 21:14
-
-
Save jkutner/2648895 to your computer and use it in GitHub Desktop.
Monkey patch Hash
This file contains hidden or 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
class Hash | |
def method_missing(name, args, &block) | |
self[name] | |
end | |
end |
This file contains hidden or 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
rule [Hash, :m, where{ |h| h.lambda {|fact| fact[:key] == "hello"} }] do |vars| | |
# do stuff | |
end |
This file contains hidden or 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
rule [Hash, :h, f(:key, c{|h, k| h[k] == "hello"})] do |v| | |
# do stuff | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment