summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Danna <steve@opscode.com>2015-01-27 08:51:52 +0000
committerSteven Danna <steve@opscode.com>2015-01-27 08:51:52 +0000
commitb7e60172d701fb042661596e4db33cdc74e0eb48 (patch)
tree22e1c600394fc7543c7e0f109e7eb317a2e1833e
parent1ba0c5dceaae318bd07cd4f9f342cb2f7f415db3 (diff)
downloadchef-ssd/issue-2542.tar.gz
Avoid 'class << self'-style class methods in Chef::ApiClientssd/issue-2542
-rw-r--r--lib/chef/api_client.rb29
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