class XMigra::IndexCollection

Public Class Methods

new(path, options={}) click to toggle source
# File lib/xmigra/index_collection.rb, line 7
def initialize(path, options={})
  @items = Hash.new
  db_specifics = options[:db_specifics]
  Dir.glob(File.join(path, '*.yaml')).each do |fpath|
    info = YAML.load_file(fpath)
    info['name'] = File.basename(fpath, '.yaml')
    index = Index.new(info)
    index.extend(db_specifics) if db_specifics
    index.file_path = File.expand_path(fpath)
    
    if Plugin.active
      next unless Plugin.active.include_index?(index)
      Plugin.active.amend_index(index)
    end
    
    @items[index.name] = index
  end
  
  if Plugin.active
    Plugin.active.each_additional_index(db_specifics) do |index|
      @items[index.name] = index
    end
  end
end

Public Instance Methods

[](name) click to toggle source
# File lib/xmigra/index_collection.rb, line 32
def [](name)
  @items[name]
end
each(&block) click to toggle source
# File lib/xmigra/index_collection.rb, line 40
def each(&block); @items.each_value(&block); end
each_definition_sql() { |definition_sql| ... } click to toggle source
# File lib/xmigra/index_collection.rb, line 43
def each_definition_sql
  each {|i| yield i.definition_sql}
end
empty?() click to toggle source
# File lib/xmigra/index_collection.rb, line 47
def empty?
  @items.empty?
end
names() click to toggle source
# File lib/xmigra/index_collection.rb, line 36
def names
  @items.keys
end