summaryrefslogtreecommitdiff
path: root/lib/chef/api_client_v1.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/api_client_v1.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/api_client_v1.rb')
-rw-r--r--lib/chef/api_client_v1.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/api_client_v1.rb b/lib/chef/api_client_v1.rb
index fcd4d91c13..8ce06ea780 100644
--- a/lib/chef/api_client_v1.rb
+++ b/lib/chef/api_client_v1.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Nuo Yan (<nuo@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -146,7 +146,7 @@ class Chef
# Private key is included if available.
#
# @return [Hash]
- def to_hash
+ def to_h
result = {
"name" => @name,
"validator" => @validator,
@@ -159,11 +159,13 @@ class Chef
result
end
+ alias_method :to_hash, :to_h
+
# The JSON representation of the object.
#
# @return [String] the JSON string.
def to_json(*a)
- Chef::JSONCompat.to_json(to_hash, *a)
+ Chef::JSONCompat.to_json(to_h, *a)
end
def self.from_hash(o)
@@ -312,7 +314,7 @@ class Chef
new_client = chef_rest_v0.post("clients", payload)
end
- Chef::ApiClientV1.from_hash(to_hash.merge(new_client))
+ Chef::ApiClientV1.from_hash(to_h.merge(new_client))
end
# As a string