def find_calls options
target = options[:target] || options[:targets]
method = options[:method] || options[:methods]
nested = options[:nested]
if options[:chained]
return find_chain options
elsif target and method and target.is_a? Array and method.is_a? Array
if target.length > method.length
calls = filter_by_target calls_by_methods(method), target
else
calls = calls_by_targets(target)
calls = filter_by_method calls, method
end
elsif target
calls = calls_by_target target
if calls and method
calls = filter_by_method calls, method
end
elsif (options.key? :target or options.key? :targets) and not target and method
calls = calls_by_method method
calls = filter_by_target calls, nil
elsif method
calls = calls_by_method method
else
raise "Invalid arguments to CallCache#find_calls: #{options.inspect}"
end
return [] if calls.nil?
calls = filter_nested calls unless nested
calls
end