Class: XMigra::IndexCollection
- Includes:
- Enumerable
- Defined in:
- lib/xmigra/index_collection.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #each(&block) ⇒ Object
- #each_definition_sql ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(path, options = {}) ⇒ IndexCollection
constructor
A new instance of IndexCollection.
- #names ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ IndexCollection
Returns a new instance of IndexCollection.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/xmigra/index_collection.rb', line 7 def initialize(path, ={}) @items = Hash.new db_specifics = [: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.(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 |
Instance Method Details
#[](name) ⇒ Object
32 33 34 |
# File 'lib/xmigra/index_collection.rb', line 32 def [](name) @items[name] end |
#each(&block) ⇒ Object
40 |
# File 'lib/xmigra/index_collection.rb', line 40 def each(&block); @items.each_value(&block); end |
#each_definition_sql ⇒ Object
43 44 45 |
# File 'lib/xmigra/index_collection.rb', line 43 def each_definition_sql each {|i| yield i.definition_sql} end |
#empty? ⇒ Boolean
47 48 49 |
# File 'lib/xmigra/index_collection.rb', line 47 def empty? @items.empty? end |
#names ⇒ Object
36 37 38 |
# File 'lib/xmigra/index_collection.rb', line 36 def names @items.keys end |