From cb34e80c908e5379f3c35e35901b033125d04d54 Mon Sep 17 00:00:00 2001 From: Andrea Campi Date: Thu, 13 Dec 2012 00:00:45 +0100 Subject: [CHEF-3249] Replace ternary operators with more explicit conditionals; split them out to separate methods for ease of maintenance. --- lib/chef/provider/template_finder.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/chef/provider/template_finder.rb b/lib/chef/provider/template_finder.rb index 3c402f6aae..e1662a88f1 100644 --- a/lib/chef/provider/template_finder.rb +++ b/lib/chef/provider/template_finder.rb @@ -29,15 +29,31 @@ class Chef def find(template_name, options = {}) if options[:local] - return options[:source] ? options[:source] : template_name + return local_template_source(template_name, options) end - cookbook_name = options[:cookbook] ? options[:cookbook] : @cookbook_name - + cookbook_name = find_cookbook_name(options) cookbook = @run_context.cookbook_collection[cookbook_name] cookbook.preferred_filename_on_disk_location(@node, :templates, template_name) end + + protected + def local_template_source(name, options) + if options[:source] + options[:source] + else + name + end + end + + def find_cookbook_name(options) + if options[:cookbook] + options[:cookbook] + else + @cookbook_name + end + end end end end -- cgit v1.2.1