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

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

  attr_accessor :config

  def initialize(config)
    @config = config
  end

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

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

  ##
  # write has to return the storage id of the written
  # entry.
  #
  def write(model)
    raise "#{self.class}: write not implemented"
  end

  def config_key
    self.class.to_s.to_sym
  end
end