diff options
author | John Keiser <jkeiser@opscode.com> | 2014-04-22 09:26:37 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-04-22 09:26:37 -0700 |
commit | 9a32e76ef798ad122544eaf3a5b4c0b45f8d8152 (patch) | |
tree | 82b60132f17cc353d0060137e51f6a64cbc5462e | |
parent | 38ebd63ba03b98791375a39404c55801cea3685e (diff) | |
download | chef-zero-9a32e76ef798ad122544eaf3a5b4c0b45f8d8152.tar.gz |
Add option for exists? to work on all things
-rw-r--r-- | lib/chef_zero/data_store/memory_store_v2.rb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/chef_zero/data_store/memory_store_v2.rb b/lib/chef_zero/data_store/memory_store_v2.rb index 97402c1..fd93506 100644 --- a/lib/chef_zero/data_store/memory_store_v2.rb +++ b/lib/chef_zero/data_store/memory_store_v2.rb @@ -130,14 +130,17 @@ module ChefZero def list(path) dir = _get(path) if !dir.is_a? Hash - raise "list only works with directories (#{path} = #{dir.class}" + raise "list only works with directories (#{path} = #{dir.class})" end dir.keys.sort end - def exists?(path) + def exists?(path, options = {}) begin - get(path) + value = _get(path) + if value.is_a?(Hash) && !options[:allow_dirs] + raise "exists? does not work with directories (#{path} = #{dir.class})" + end return true rescue DataNotFoundError return false @@ -148,7 +151,7 @@ module ChefZero begin dir = _get(path) if !dir.is_a? Hash - raise "exists_dir? only works with directories (#{path} = #{dir.class}" + raise "exists_dir? only works with directories (#{path} = #{dir.class})" end return true rescue DataNotFoundError |