class XMigra::NewAccessArtifactAdder
Public Class Methods
new(path)
click to toggle source
Calls superclass method
# File lib/xmigra/new_access_artifact_adder.rb, line 16 def initialize(path) super(path) end
Public Instance Methods
add_artifact(type, name)
click to toggle source
# File lib/xmigra/new_access_artifact_adder.rb, line 20 def add_artifact(type, name) access_dir = @path.join(ACCESS_SUBDIR) FileUtils.mkdir_p(access_dir) unless access_dir.exist? new_fpath = access_dir.join(name + '.yaml') raise(XMigra::Error, "Access object \"#{new_fpath.basename}\" already exists") if new_fpath.exist? template_method = begin method("#{type}_definition_template_sql".to_sym) rescue NameError proc {''} end new_data = { 'define'=>type.to_s, 'sql'=>template_method.call.dup.extend(LiteralYamlStyle), } File.open(new_fpath, "w") do |f| $xmigra_yamler.dump(new_data, f) end return new_fpath end