Sha256: a0ddd443fbe82953efc458b06e616f555cf90ea748035d60a76a5290297f37eb
Contents?: true
Size: 1.59 KB
Versions: 5
Compression:
Stored size: 1.59 KB
Contents
module Naf class ApplicationType < NafBase # Protect from mass-assignment issue attr_accessible :enabled, :script_type_name, :description, :invocation_method SCRIPT_RUNNER = "#{Gem.ruby} #{Rails.root}/script/rails runner" #--------------------- # *** Associations *** #+++++++++++++++++++++ has_many :applications, class_name: "::Naf::Application" has_many :historical_jobs, class_name: "::Naf::HistoricalJob" #-------------------- # *** Validations *** #++++++++++++++++++++ validates :script_type_name, :invocation_method, presence: true #------------------------- # *** Instance Methods *** #+++++++++++++++++++++++++ def spawn(job) self.send(invocation_method.to_sym, job) end def invoke(job, command) Process.spawn({ "NAF_JOB_ID" => job.id.to_s }, command) end def rails_invocator(job) invoke(job, SCRIPT_RUNNER + " " + job.command) end def bash_command_invocator(job) invoke(job, job.command) end def bash_script_invocator(job) invoke(job, job.command) end def ruby_script_invocator(job) invoke(job, job.command) end def self.rails @rails ||= find_by_script_type_name('rails') end def self.ruby @ruby ||= find_by_script_type_name('ruby') end def self.bash_command @bash_command ||= find_by_script_type_name('bash command') end def self.bash_script @bash_script ||= find_by_script_type_name('bash script') end end end
Version data entries
5 entries across 5 versions & 1 rubygems