We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f610abc commit 84e02c8Copy full SHA for 84e02c8
golf_prelude.rb
@@ -3,7 +3,10 @@
3
class Object
4
@@golf_hash = {}
5
def method_missing m, *a, &b
6
- t = @@golf_hash[[m,self.class]] ||= (methods + private_methods).sort.find{|e|/^#{m}/=~e}
+ t = @@golf_hash.fetch(k = [m,self.class]) do
7
+ r = /^#{m.to_s.gsub(/(?<=\w)(?=_)/, '\w*?')}/
8
+ @@golf_hash[k] = (methods + private_methods).sort.find{|e|r=~e}
9
+ end
10
t ? __send__(t, *a, &b) : super
11
end
12
0 commit comments