summaryrefslogtreecommitdiff
path: root/lib/chef/data_bag_item.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/data_bag_item.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/data_bag_item.rb')
-rw-r--r--lib/chef/data_bag_item.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index 0d07daa39e..63b4060baa 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -101,13 +101,15 @@ class Chef
"data_bag_item_#{data_bag_name}_#{id}"
end
- def to_hash
+ def to_h
result = raw_data.dup
result["chef_type"] = "data_bag_item"
result["data_bag"] = data_bag.to_s
result
end
+ alias_method :to_hash, :to_h
+
# Serialize this object as a hash
def to_json(*a)
result = {
@@ -180,9 +182,9 @@ class Chef
end
def ==(other)
- other.respond_to?(:to_hash) &&
+ other.respond_to?(:to_h) &&
other.respond_to?(:data_bag) &&
- (other.to_hash == to_hash) &&
+ (other.to_h == to_h) &&
(other.data_bag.to_s == data_bag.to_s)
end