Class: XMigra::AccessArtifactCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable, TSort
Defined in:
lib/xmigra/access_artifact_collection.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ AccessArtifactCollection



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/access_artifact_collection.rb', line 7

def initialize(path, options={})
  @items = Hash.new
  db_specifics = options[:db_specifics]
  filename_metavariable = options[:filename_metavariable]
  filename_metavariable = filename_metavariable.dup.freeze if filename_metavariable
  
  XMigra.each_access_artifact(path) do |artifact|
    artifact.extend(db_specifics) if db_specifics
    artifact.filename_metavariable = filename_metavariable
    
    if Plugin.active
      next unless Plugin.active.include_access_artifact?(artifact)
      Plugin.active.amend_access_artifact(artifact)
    end
    
    @items[artifact.name] = artifact
  end
  
  if Plugin.active
    Plugin.active.each_additional_access_artifact(db_specifics) do |artifact|
      @items[artifact.name] = artifact
    end
  end
end

Instance Method Details

#[](name) ⇒ Object



32
33
34
# File 'lib/xmigra/access_artifact_collection.rb', line 32

def [](name)
  @items[name]
end

#at_path(fpath) ⇒ Object



40
41
42
43
# File 'lib/xmigra/access_artifact_collection.rb', line 40

def at_path(fpath)
  fpath = File.expand_path(fpath)
  return find {|i| i.file_path == fpath}
end

#each(&block) ⇒ Object Also known as: tsort_each_node



45
# File 'lib/xmigra/access_artifact_collection.rb', line 45

def each(&block); @items.each_value(&block); end

#each_definition_sqlObject



57
58
59
60
61
# File 'lib/xmigra/access_artifact_collection.rb', line 57

def each_definition_sql
  tsort_each do |artifact|
    yield artifact.definition_sql
  end
end

#namesObject



36
37
38
# File 'lib/xmigra/access_artifact_collection.rb', line 36

def names
  @items.keys
end

#tsort_each_child(node) ⇒ Object



48
49
50
51
52
# File 'lib/xmigra/access_artifact_collection.rb', line 48

def tsort_each_child(node)
  node.depends_on.each do |child|
    yield @items[child]
  end
end