Sha256: 0727e728d141d50608143c7acd466caa40e2f4d4c93a3e031dd2f582b7751c92

Contents?: true

Size: 978 Bytes

Versions: 4

Compression:

Stored size: 978 Bytes

Contents

module ForemanSalt
  class SaltModule < ActiveRecord::Base
    include Taxonomix
    include Authorizable

    before_destroy EnsureNotUsedBy.new(:hosts, :hostgroups)
    has_and_belongs_to_many :hosts, :class_name => "::Host::Managed", :join_table => "hosts_salt_modules",
                            :association_foreign_key => 'host_id'

    has_and_belongs_to_many :hostgroups, :class_name => "::Hostgroup", :join_table => "hostgroups_salt_modules"

    validates :name, :uniqueness => true, :presence => true, :format => { :with => /\A(?:[\w\d]+\.{0,1})+[^\.]\z/, :message => N_("must be alphanumeric, can contain dots and must not contain spaces") }

    default_scope lambda {
      order("salt_modules.name")
    }

    scoped_search :on => :name, :complete_value => true
    scoped_search :in => :hostgroups, :on => :name, :complete_value => true, :rename => :hostgroup
    scoped_search :in => :hosts, :on => :name, :complete_value => true, :rename => :host
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_salt-1.1.0 app/models/foreman_salt/salt_module.rb
foreman_salt-1.0.0 app/models/foreman_salt/salt_module.rb
foreman_salt-0.0.4 app/models/foreman_salt/salt_module.rb
foreman_salt-0.0.3 app/models/foreman_salt/salt_module.rb