Sha256: 52ce6c33b67dd77161c06f8044c766b262c04acebf2ee080fbbe0130b23c421c

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

class RemoteExecutionFeature < ActiveRecord::Base
  validates :label, :name, :presence => true, :uniqueness => true

  belongs_to :job_template

  extend FriendlyId
  friendly_id :label

  def provided_input_names
    self.provided_inputs.to_s.split(',').map(&:strip)
  end

  def provided_input_names=(values)
    self.provided_inputs = Array(values).join(',')
  end

  def self.feature(label)
    self.find_by_label(label) || raise(::Foreman::Exception.new(N_('Unknown remote execution feature %s'), label))
  end

  def self.register(label, name, options = {})
    return false unless RemoteExecutionFeature.table_exists?
    options.assert_valid_keys(:provided_inputs, :description)
    feature = self.find_by_label(label)
    if feature.nil?
      feature = self.create!(:label => label, :name => name, :provided_input_names => options[:provided_inputs], :description => options[:description])
    else
      feature.update_attributes!(:name => name, :provided_input_names => options[:provided_inputs], :description => options[:description])
    end
    return feature
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_remote_execution-1.2.2 app/models/remote_execution_feature.rb
foreman_remote_execution-1.2.1 app/models/remote_execution_feature.rb
foreman_remote_execution-1.2.0 app/models/remote_execution_feature.rb
foreman_remote_execution-1.1.1 app/models/remote_execution_feature.rb
foreman_remote_execution-1.1.0 app/models/remote_execution_feature.rb