Class: Mdm::Tag

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Metasploit::Model::Search
Defined in:
app/models/mdm/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostsActiveRecord::Relation<Mdm::Host> (readonly)

Host that are tagged with this tag.

Returns:



29
# File 'app/models/mdm/tag.rb', line 29

has_many :hosts, :through => :hosts_tags, :class_name => 'Mdm::Host'

#hosts_tagsActiveRecord::Relation<Mdm::HostTag>

Joins #hosts to this tag.

Returns:



12
13
14
15
# File 'app/models/mdm/tag.rb', line 12

has_many :hosts_tags,
class_name: 'Mdm::HostTag',
dependent: :destroy,
inverse_of: :tag

Instance Method Details

#destroy_if_orphanedvoid

This method returns an undefined value.

Destroy this tag if it has no #hosts_tags



62
63
64
65
66
67
68
# File 'app/models/mdm/tag.rb', line 62

def destroy_if_orphaned
  self.class.transaction do
    if hosts_tags.empty?
      destroy
    end
  end
end

#to_sObject



70
71
72
# File 'app/models/mdm/tag.rb', line 70

def to_s
  name
end