summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <jkeiser@opscode.com>2014-04-22 09:26:37 -0700
committerJohn Keiser <jkeiser@opscode.com>2014-04-22 09:26:37 -0700
commit9a32e76ef798ad122544eaf3a5b4c0b45f8d8152 (patch)
tree82b60132f17cc353d0060137e51f6a64cbc5462e
parent38ebd63ba03b98791375a39404c55801cea3685e (diff)
downloadchef-zero-9a32e76ef798ad122544eaf3a5b4c0b45f8d8152.tar.gz
Add option for exists? to work on all things
-rw-r--r--lib/chef_zero/data_store/memory_store_v2.rb11
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