summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-09-28 09:11:59 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2019-09-28 09:11:59 +0530
commit697d773d83eba339223db67511e5b2f538e3a962 (patch)
treeff57a79bfa453508e356faea8e87aa3ea445c013
parent644ae14fc7c9fd92b95d762d004c619f755a0a3c (diff)
downloadchef-697d773d83eba339223db67511e5b2f538e3a962.tar.gz
Add to_yaml methods for AttrArray & VividMash
- Fix to_json Wrong number of argument while calling on object of Node::Attribute. - Allowed to_yaml method in Node::Attribute. Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/node/attribute.rb2
-rw-r--r--lib/chef/node/attribute_collections.rb8
-rw-r--r--lib/chef/node/mixin/immutablize_array.rb1
-rw-r--r--lib/chef/node/mixin/immutablize_hash.rb1
4 files changed, 12 insertions, 0 deletions
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index 0beddf25f5..8bccc9a05d 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -148,7 +148,9 @@ class Chef
to_a
to_h
to_hash
+ to_json
to_set
+ to_yaml
value?
values
values_at
diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb
index dadc209ae9..bfa814934d 100644
--- a/lib/chef/node/attribute_collections.rb
+++ b/lib/chef/node/attribute_collections.rb
@@ -65,6 +65,10 @@ class Chef
Array.new(map { |e| safe_dup(e) })
end
+ def to_yaml(*opts)
+ to_a.to_yaml(*opts)
+ end
+
private
def convert_value(value)
@@ -172,6 +176,10 @@ class Chef
Mash.new(self)
end
+ def to_yaml(*opts)
+ to_h.to_yaml(*opts)
+ end
+
prepend Chef::Node::Mixin::StateTracking
end
end
diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb
index e9cbb2142a..36b8c33528 100644
--- a/lib/chef/node/mixin/immutablize_array.rb
+++ b/lib/chef/node/mixin/immutablize_array.rb
@@ -119,6 +119,7 @@ class Chef
to_h
to_plist
to_set
+ to_yaml
transpose
union
uniq
diff --git a/lib/chef/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb
index 8c0d1c9509..6ffa42a4f3 100644
--- a/lib/chef/node/mixin/immutablize_hash.rb
+++ b/lib/chef/node/mixin/immutablize_hash.rb
@@ -116,6 +116,7 @@ class Chef
to_proc
to_set
to_xml_attributes
+ to_yaml
transform_keys
transform_values
uniq