summaryrefslogtreecommitdiff
path: root/lib/chef/mixin/params_validate.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-06-04 10:52:07 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-23 15:23:02 -0700
commit9916aee174a54c58d00fbea35c0e2c01ac77fef1 (patch)
tree12809813373589c4e24432b860b89fd0f1e4dc40 /lib/chef/mixin/params_validate.rb
parentf47252a75191d96e169abdc7c9d84aa6e50df708 (diff)
downloadchef-9916aee174a54c58d00fbea35c0e2c01ac77fef1.tar.gz
Add coercion
Diffstat (limited to 'lib/chef/mixin/params_validate.rb')
-rw-r--r--lib/chef/mixin/params_validate.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
index ebab964b74..926387b888 100644
--- a/lib/chef/mixin/params_validate.rb
+++ b/lib/chef/mixin/params_validate.rb
@@ -276,6 +276,14 @@ class Chef
false
end
end
+
+ def _pv_coerce(opts, key, coercer)
+ if opts.has_key?(key.to_s)
+ opts[key.to_s] = instance_exec(opts[key], &coercer)
+ elsif opts.has_key?(key.to_sym)
+ opts[key.to_sym] = instance_exec(opts[key], &coercer)
+ end
+ end
end
end
end