Sha256: 1605154eccd7eca398e1bb8cfc2815fbf262e24afe329d065f453798bc0d4bbc
Contents?: true
Size: 757 Bytes
Versions: 2
Compression:
Stored size: 757 Bytes
Contents
# This class is a shim to handle the importing of templates via the # foreman_templates plugin. It expects a method like # def import(name, text, metadata) # but REx already has an import! method, so this class provides the # translation layer. class JobTemplateImporter def self.import!(name, text, _metadata) template = JobTemplate.import( text.sub(/^name: .*$/, "name: #{name}").sub(/^model: .*$/, ''), :update => true ) c_or_u = template.new_record? ? 'Created' : 'Updated' id_string = ('id' + template.id) rescue '' result = " #{c_or_u} Template #{id_string}:#{name}" { :old => template.template_was, :new => template.template, :status => template.save, :result => result } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_remote_execution-1.3.0 | app/models/job_template_importer.rb |
foreman_remote_execution-1.2.2 | app/models/job_template_importer.rb |