summaryrefslogtreecommitdiff
path: root/lib/chef/cookbook_manifest.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-09-26 22:22:29 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-09-26 22:22:29 -0700
commit8400f4cb7d977896531ae277fdcf3398dc2d4c6c (patch)
tree33b8b5ba385366457de4990636daa143d64f1043 /lib/chef/cookbook_manifest.rb
parent8daa1c6598182777802eba6a74928f28a32f6835 (diff)
downloadchef-8400f4cb7d977896531ae277fdcf3398dc2d4c6c.tar.gz
replace some instances of to_hash with to_hlcg/to-h-cleanup
to_hash on a lot of these objects should go away, but even eliminating all our calls to to_hash on these objects internally is difficult. (e.g. converting the knife ui code to call #to_h means we wind up calling nil#to_h which "helpfully" becomes '{}' which is hilarious and i don't know why someone thought that was a good idea). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/cookbook_manifest.rb')
-rw-r--r--lib/chef/cookbook_manifest.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/cookbook_manifest.rb b/lib/chef/cookbook_manifest.rb
index c0c5b57a60..3f38f9cf29 100644
--- a/lib/chef/cookbook_manifest.rb
+++ b/lib/chef/cookbook_manifest.rb
@@ -1,5 +1,5 @@
# Author:: Daniel DeLeo (<dan@chef.io>)
-# Copyright:: Copyright 2015-2016, Chef Software Inc.
+# Copyright:: Copyright 2015-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,7 +40,7 @@ class Chef
def_delegator :@cookbook_version, :frozen_version?
# Create a new CookbookManifest object for the given `cookbook_version`.
- # You can subsequently call #to_hash to get a Hash representation of the
+ # You can subsequently call #to_h to get a Hash representation of the
# cookbook_version in the "manifest" format, or #to_json to get a JSON
# representation of the cookbook_version.
#
@@ -119,12 +119,14 @@ class Chef
@policy_mode
end
- def to_hash
- CookbookManifestVersions.to_hash(self)
+ def to_h
+ CookbookManifestVersions.to_h(self)
end
+ alias_method :to_hash, :to_h
+
def to_json(*a)
- result = to_hash
+ result = to_h
result["json_class"] = "Chef::CookbookVersion"
Chef::JSONCompat.to_json(result, *a)
end
@@ -321,5 +323,6 @@ class Chef
def_versioned_delegator :from_hash
def_versioned_delegator :to_hash
+ def_versioned_delegator :to_h
end
end