Class: RemoteExecutionFeature

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/remote_execution_feature.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.feature(label) ⇒ Object



19
20
21
# File 'app/models/remote_execution_feature.rb', line 19

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

.register(label, name, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/remote_execution_feature.rb', line 23

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

Instance Method Details

#provided_input_namesObject



11
12
13
# File 'app/models/remote_execution_feature.rb', line 11

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

#provided_input_names=(values) ⇒ Object



15
16
17
# File 'app/models/remote_execution_feature.rb', line 15

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