Sha256: 14e8add85797ecb1345e89fdf47f4fbf8578e39cd7f0c679c6ae53c36d8a46bf

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 Bytes

Contents

require 'chef_fs/file_system/base_fs_dir'
require 'chef_fs/file_system/rest_list_entry'

# TODO: take environment into account

module ChefFS
  module FileSystem
    class DataBagDir < RestListDir
      def initialize(name, parent, exists = nil)
        super(name, parent)
        @exists = nil
      end

      def dir?
        exists?
      end

      def read
        # This will only be called if dir? is false, which means exists? is false.
        raise ChefFS::FileSystem::NotFoundException, path_for_printing
      end

      def exists?
        if @exists.nil?
          @exists = parent.children.any? { |child| child.name == name }
        end
        @exists
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-essentials-0.1.1 lib/chef_fs/file_system/data_bag_dir.rb