Sha256: 11832f58c18d8915002faa298bede23940c0c777c3b2679d930a69d3a08533ea

Contents?: true

Size: 660 Bytes

Versions: 125

Compression:

Stored size: 660 Bytes

Contents

class TemplateInvocationInputValue < ApplicationRecord

  belongs_to :template_invocation
  belongs_to :template_input

  validates :value, :presence => true, :if => proc { |v| v.template_input.required? || v.value.nil? }

  validates :value, :inclusion => { :in => proc { |v| options_for_template_input v.template_input } },
                    :if => proc { |v| v.template_input.input_type == 'user' && v.template_input.options_array.present? }

  class << self

    private

    def options_for_template_input(template_input)
      options = template_input.options_array
      options += [''] unless template_input.required?
      options
    end
  end
end

Version data entries

125 entries across 125 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.2 app/models/template_invocation_input_value.rb
foreman_remote_execution-14.1.1 app/models/template_invocation_input_value.rb
foreman_remote_execution-14.1.0 app/models/template_invocation_input_value.rb
foreman_remote_execution-14.0.2 app/models/template_invocation_input_value.rb
foreman_remote_execution-14.0.1 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.6 app/models/template_invocation_input_value.rb
foreman_remote_execution-14.0.0 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.5 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.4 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.3 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.2 app/models/template_invocation_input_value.rb
foreman_remote_execution-12.0.7 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.1 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.2.0 app/models/template_invocation_input_value.rb
foreman_remote_execution-10.1.3 app/models/template_invocation_input_value.rb
foreman_remote_execution-13.0.0 app/models/template_invocation_input_value.rb
foreman_remote_execution-12.0.5 app/models/template_invocation_input_value.rb
foreman_remote_execution-12.0.4 app/models/template_invocation_input_value.rb
foreman_remote_execution-12.0.1 app/models/template_invocation_input_value.rb
foreman_remote_execution-12.0.2 app/models/template_invocation_input_value.rb