class Onoma::Migrator::Reference

Public Class Methods

new() click to toggle source
# File lib/onoma/migrator/reference.rb, line 14
def initialize
  @set = if Onoma.reference_path.exist?
           Onoma::NomenclatureSet.load_file(Onoma.reference_path)
         else
           Onoma::NomenclatureSet.new
         end
end
run(migration) click to toggle source
# File lib/onoma/migrator/reference.rb, line 4
def self.run(migration)
  ref = new
  migration.each_action do |action|
    ref.send(action.action_name, action)
  end
  ref.version = migration.number
  puts "Write DB in #{Onoma.reference_path.relative_path_from(Onoma.root)}"
  ref.write
end

Public Instance Methods

item_change(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 58
def item_change(action)
  @set.change_item(action.nomenclature, action.name, action.changes)
end
item_creation(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 54
def item_creation(action)
  @set.add_item(action.nomenclature, action.name, action.options)
end
item_merging(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 62
def item_merging(action)
  @set.merge_item(action.nomenclature, action.name, action.into)
end
item_removal(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 66
def item_removal(action)
  @set.remove_item(action.nomenclature, action.name)
end
nomenclature_change(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 38
def nomenclature_change(action)
  @set.change_nomenclature(action.nomenclature, action.changes)
end
nomenclature_creation(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 34
def nomenclature_creation(action)
  @set.add_nomenclature(action.name, action.options)
end
nomenclature_removal(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 42
def nomenclature_removal(action)
  @set.remove_nomenclature(action.nomenclature)
end
property_change(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 50
def property_change(action)
  @set.change_property(action.nomenclature, action.name, action.changes)
end
property_creation(action) click to toggle source
# File lib/onoma/migrator/reference.rb, line 46
def property_creation(action)
  @set.add_property(action.nomenclature, action.name, action.type, action.options)
end
version() click to toggle source
# File lib/onoma/migrator/reference.rb, line 22
def version
  @set.version
end
version=(number) click to toggle source
# File lib/onoma/migrator/reference.rb, line 26
def version=(number)
  @set.version = number
end
write() click to toggle source
# File lib/onoma/migrator/reference.rb, line 30
def write
  File.write(Onoma.reference_path, @set.to_xml)
end