Sha256: aebf06b6c5e531104a221b05b312e4ef3ec1446717624e59317a1e43d2d27ded

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

# Represents the variables used in Ansible to parameterize playbooks
class AnsibleVariable < LookupKey
  include Foreman::ObservableModel

  belongs_to :ansible_role, :inverse_of => :ansible_variables
  validates :ansible_role_id, :presence => true
  before_validation :cast_default_value, :if => :override?
  validates :key, :uniqueness => { :scope => :ansible_role_id }
  scoped_search :on => :key, :aliases => [:name], :complete_value => true
  scoped_search :on => :imported, :complete_value => { :true => true, :false => false }
  scoped_search :relation => :ansible_role, :on => :name,
                :complete_value => true, :rename => :ansible_role

  set_crud_hooks :ansible_variable

  def ansible?
    true
  end

  def self.humanize_class_name(options = nil)
    if options.present?
      super
    else
      "Ansible variable"
    end
  end

  def editable_by_user?
    AnsibleVariable.authorized(:edit_ansible_variables).
      where(:id => id).exists?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 app/models/ansible_variable.rb
foreman_ansible-15.0.1 app/models/ansible_variable.rb
foreman_ansible-15.0.0 app/models/ansible_variable.rb
foreman_ansible-14.2.2 app/models/ansible_variable.rb