class ChefZero::DataStore::V2ToV1Adapter

Attributes

real_store[R]
single_org[R]

Public Class Methods

new() click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 24
def initialize
  @single_org = 'chef'
end

Public Instance Methods

clear() click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 31
def clear
  real_store.clear
  real_store.create_dir([ 'organizations' ], single_org)
end
create(path, name, data, *options) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 42
def create(path, name, data, *options)
  fix_exceptions do
    real_store.create(fix_path(path), name, data, *options)
  end
end
create_dir(path, name, *options) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 36
def create_dir(path, name, *options)
  fix_exceptions do
    real_store.create_dir(fix_path(path), name, *options)
  end
end
delete(path) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 60
def delete(path)
  fix_exceptions do
    real_store.delete(fix_path(path))
  end
end
delete_dir(path, *options) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 66
def delete_dir(path, *options)
  fix_exceptions do
    real_store.delete_dir(fix_path(path), *options)
  end
end
exists?(path) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 78
def exists?(path)
  fix_exceptions do
    real_store.exists?(fix_path(path))
  end
end
exists_dir?(path) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 84
def exists_dir?(path)
  fix_exceptions do
    real_store.exists_dir?(fix_path(path))
  end
end
get(path, request=nil) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 48
def get(path, request=nil)
  fix_exceptions do
    real_store.get(fix_path(path), request)
  end
end
list(path) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 72
def list(path)
  fix_exceptions do
    real_store.list(fix_path(path))
  end
end
set(path, data, *options) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 54
def set(path, data, *options)
  fix_exceptions do
    real_store.set(fix_path(path), data, *options)
  end
end

Protected Instance Methods

fix_exceptions() { || ... } click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 92
def fix_exceptions
  begin
    yield
  rescue DataAlreadyExistsError => e
    raise DataAlreadyExistsError.new(e.path[2..-1], e)
  rescue DataNotFoundError => e
    raise DataNotFoundError.new(e.path[2..-1], e)
  end
end
fix_path(path) click to toggle source
# File lib/chef_zero/data_store/v2_to_v1_adapter.rb, line 102
def fix_path(path)
  [ 'organizations', single_org ] + path
end