Sha256: 00c2b2d9747853639d10e5f67bb03723856149d1f4b4142dc7ac107e2cc6e026
Contents?: true
Size: 973 Bytes
Versions: 2
Compression:
Stored size: 973 Bytes
Contents
module Fsck def method_missing(method_name, *args, &block) fscked_method = __fsck_method__(method_name) if fscked_method target = singleton_methods.include?(fscked_method) ? singleton_class : self.class target.class_exec { alias_method(method_name, fscked_method) } send(method_name, *args, &block) else super end end def respond_to_missing?(method_name, include_private = false) !!__fsck_method__(method_name) end private def __fsck_method_regex_str__(method) words = method.to_s.delete("!?=").split("_").map { |w| Regexp.escape(w) } "(\\w*_)?#{words.join('\w*_\w*')}(_\\w*)?" end def __fsck_method__(method_name) fscked_method = method_name.to_s if punctuation = fscked_method[/[!?=]$/] fscked_method.chop! end matches = methods.select do |method| fscked_method =~ /^#{__fsck_method_regex_str__(method)}#{punctuation}$/ end matches.max_by(&:length) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fsck-0.0.5.1 | lib/fsck.rb |
fsck-0.0.5 | lib/fsck.rb |