diff options
author | Andrea Campi <andrea.campi@zephirworks.com> | 2012-12-13 00:00:45 +0100 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2012-12-14 11:10:28 -0800 |
commit | cb34e80c908e5379f3c35e35901b033125d04d54 (patch) | |
tree | 3ef33beb2daed53cc629a5050041db208391a66f /lib | |
parent | 4eb1b589f1d6c216be5788c501c4328a4967ba4b (diff) | |
download | chef-cb34e80c908e5379f3c35e35901b033125d04d54.tar.gz |
[CHEF-3249] Replace ternary operators with more explicit conditionals; split them out to separate methods for ease of maintenance.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/template_finder.rb | 22 |
1 files changed, 19 insertions, 3 deletions
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 |