diff options
author | Scott Hain <shain@getchef.com> | 2014-07-14 15:27:16 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-09-04 15:52:23 -0700 |
commit | f0e61d1069f9cde9f1d96f8bc9907c99485c4aaf (patch) | |
tree | bed72f1832baf93752c7a37650f82152df498eef /lib/chef | |
parent | 47f3b3d93cfd21831debcb4db22ddb7005f28763 (diff) | |
download | chef-f0e61d1069f9cde9f1d96f8bc9907c99485c4aaf.tar.gz |
updated partial again
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/search/query.rb | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/chef/search/query.rb b/lib/chef/search/query.rb index c93c12082c..5efea944de 100644 --- a/lib/chef/search/query.rb +++ b/lib/chef/search/query.rb @@ -38,11 +38,29 @@ class Chef # This search is only kept for backwards compatibility, since the results of the # new filtered search method will be in a slightly different format def partial_search(type, query='*:*', *args, &block) - results = search(type,query,args,&block) + # accept both types of args + if args.length == 1 && args[0].is_a?(Hash) + args_hash = args[0] + args_hash[:filter_result] = args_hash[:keys] + else + args_hash = {} + args_hash[:sort] = args[0] if args.length >= 1 + args_hash[:start] = args[1] if args.length >= 2 + args_hash[:rows] = args[2] if args.length >= 3 + end + unless block.nil? + raw_results = search(type,query,args_hash) + else + raw_results = search(type,query,args,&block) + end + results = Array.new + raw_results[0].each do |r| + results << r + end + return results end - # # New search input, designed to be backwards compatible with the old method signature # 'type' and 'query' are the same as before, args now will accept either a Hash of |