diff options
author | Pete Higgins <pete@peterhiggins.org> | 2020-11-09 17:04:59 -0800 |
---|---|---|
committer | Pete Higgins <pete@peterhiggins.org> | 2020-11-09 17:04:59 -0800 |
commit | 38b2e9f9f67ff6e5fcfbf50beb9dd969cb594eb3 (patch) | |
tree | 3fb5fe0cf4e63873edbc2cb67adef230b4cedbfa | |
parent | f6f186fa5daf93f5603f76c0498b1a97c73375ea (diff) | |
download | chef-38b2e9f9f67ff6e5fcfbf50beb9dd969cb594eb3.tar.gz |
Refactor to_json_pretty to avoid creating a hash.cleanup-jsoncompat
Signed-off-by: Pete Higgins <pete@peterhiggins.org>
-rw-r--r-- | lib/chef/json_compat.rb | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb index f545c71373..b5c9072f6f 100644 --- a/lib/chef/json_compat.rb +++ b/lib/chef/json_compat.rb @@ -53,10 +53,8 @@ class Chef end def to_json_pretty(obj, opts = nil) - opts ||= {} - options_map = {} - options_map[:pretty] = true - options_map[:indent] = opts[:indent] if opts.key?(:indent) + options_map = { pretty: true } + options_map[:indent] = opts[:indent] if opts.respond_to?(:key?) && opts.key?(:indent) to_json(obj, options_map).chomp end |