lib/abstractivator/enumerable_ext.rb in abstractivator-0.0.23 vs lib/abstractivator/enumerable_ext.rb in abstractivator-0.0.24
- old
+ new
@@ -39,11 +39,11 @@
result = self.outer_join(left, right, get_left_key, get_right_key, sentinel, sentinel)
result.reject { |pair| pair.first == sentinel || pair.last == sentinel }
end
def self.get_default(default, other_side_value)
- proc?(default) ? default.(other_side_value) : default
+ default.callable? ? default.call(other_side_value) : default
end
def self.proc?(x)
x.respond_to?(:call)
end
@@ -71,10 +71,10 @@
orig_detect = instance_method(:detect)
define_method :detect do |*args, &block|
detect = orig_detect.bind(self)
- if args.size == 1 && !args.first.respond_to?(:call) && block
+ if args.size == 1 && !args.first.callable? && block
value = args.first
detect.call {|x| block.call(x) == value}
elsif args.size == 2 && !block
attr_name, value = args
detect.call {|x| x.send(attr_name) == value}