storage.rb 721 Bytes
module DsAdmin::Storage
  include Enumerable

  DsAdmin::Storage.autoload(:Ldap, 'storage/ldap')
  DsAdmin::Storage.autoload(:Mysql, 'storage/mysql')
  DsAdmin::Storage.autoload(:Config, 'storage/config')

  attr_accessor :config

  def initialize(config)
    @config = config
  end

  def each(&block)
    read.each(&block)
  end

  ##
  # We don't need this....the 'id' is a storage id and as
  # thus returned after successfully writing a new entry.
  #
  def create_id(model)
    return "dummy id for #{model.inspect}"
  end

  def read
    throw "#{self.class}: read not implemented"
  end

  def write(model)
    throw "#{self.class}: write not implemented"
  end

  def to_sym
    self.class.to_s.to_sym
  end
end