diff options
author | Steven Danna <steve@opscode.com> | 2015-01-27 08:51:52 +0000 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2015-02-09 21:19:45 -0500 |
commit | 0e13f128597cfa407f3d8377a12f4b67cf60af59 (patch) | |
tree | 1f4e99b2f641ac4ce214e82761aca330e9bebbf5 /lib/chef/api_client.rb | |
parent | d6a4671ccc3df7ef8fabeb417971cb133de10ad7 (diff) | |
download | chef-0e13f128597cfa407f3d8377a12f4b67cf60af59.tar.gz |
Avoid 'class << self'-style class methods in Chef::ApiClient
Diffstat (limited to 'lib/chef/api_client.rb')
-rw-r--r-- | lib/chef/api_client.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/chef/api_client.rb b/lib/chef/api_client.rb index c27dfe82ba..a3346b5b68 100644 --- a/lib/chef/api_client.rb +++ b/lib/chef/api_client.rb @@ -124,21 +124,22 @@ class Chef Chef::JSONCompat.to_json(to_hash, *a) end - class << self - def from_hash(o) - client = Chef::ApiClient.new - client.name(o["name"] || o["clientname"]) - client.private_key(o["private_key"]) if o.key?("private_key") - client.public_key(o["public_key"]) - client.admin(o["admin"]) - client.validator(o["validator"]) - client - end - alias :json_create :from_hash + def self.from_hash(o) + client = Chef::ApiClient.new + client.name(o["name"] || o["clientname"]) + client.private_key(o["private_key"]) if o.key?("private_key") + client.public_key(o["public_key"]) + client.admin(o["admin"]) + client.validator(o["validator"]) + client + end - def from_json(j) - Chef::ApiClient.from_hash(Chef::JSONCompat.parse(j)) - end + def self.json_create(data) + from_hash(data) + end + + def self.from_json(j) + from_hash(Chef::JSONCompat.parse(j)) end def self.http_api |