diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2018-09-26 22:22:29 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2018-09-26 22:22:29 -0700 |
commit | 8400f4cb7d977896531ae277fdcf3398dc2d4c6c (patch) | |
tree | 33b8b5ba385366457de4990636daa143d64f1043 /lib/chef/user_v1.rb | |
parent | 8daa1c6598182777802eba6a74928f28a32f6835 (diff) | |
download | chef-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/user_v1.rb')
-rw-r--r-- | lib/chef/user_v1.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/chef/user_v1.rb b/lib/chef/user_v1.rb index 293bec54a7..949f5b0909 100644 --- a/lib/chef/user_v1.rb +++ b/lib/chef/user_v1.rb @@ -1,6 +1,6 @@ # # Author:: Steven Danna (steve@chef.io) -# Copyright:: Copyright 2012-2016, Chef Software, Inc. +# Copyright:: Copyright 2012-2018, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -112,7 +112,7 @@ class Chef arg, kind_of: String) end - def to_hash + def to_h result = { "username" => @username, } @@ -128,8 +128,10 @@ class Chef result end + alias_method :to_hash, :to_h + def to_json(*a) - Chef::JSONCompat.to_json(to_hash, *a) + Chef::JSONCompat.to_json(to_h, *a) end def destroy @@ -180,7 +182,7 @@ class Chef new_user = chef_root_rest_v0.post("users", payload) end - Chef::UserV1.from_hash(to_hash.merge(new_user)) + Chef::UserV1.from_hash(to_h.merge(new_user)) end def update(new_key = false) @@ -213,7 +215,7 @@ class Chef end updated_user = chef_root_rest_v0.put("users/#{username}", payload) end - Chef::UserV1.from_hash(to_hash.merge(updated_user)) + Chef::UserV1.from_hash(to_h.merge(updated_user)) end def save(new_key = false) @@ -229,7 +231,7 @@ class Chef # Note: remove after API v0 no longer supported by client (and knife command). def reregister begin - payload = to_hash.merge({ "private_key" => true }) + payload = to_h.merge({ "private_key" => true }) reregistered_self = chef_root_rest_v0.put("users/#{username}", payload) private_key(reregistered_self["private_key"]) # only V0 supported for reregister |