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
# define benchmark from: | |
#http://www.mathewabonyi.com/articles/2007/01/11/surprise-10min-benchmark-eval-class_eval-instance_eval-define_method-bind#trackbacks | |
# but we're interested in the speed of calling the method not only defining it | |
# results with ruby 1.9.2-p180 on mbp i7 | |
require 'benchmark' | |
class A; def meth1; true; end; end |
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
def keys(hash) | |
model.debug("#{model.name}.find: #{key} : #{hash}") | |
[].tap do |keys| | |
hash.each do |attr, values| | |
# nb: String is Enumerable in 1.8.x... | |
attr_type = model.types[attr] | |
if !(Enumerable === values) || ( attr_type && attr_type < Enumerable && attr_type != String ) | |
Array(values).each do |v| | |
keys << model.index_key_for(attr, v) | |
end |