Class: Mdm::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Mdm::Tag
- Includes:
- Metasploit::Model::Search
- Defined in:
- app/models/mdm/tag.rb
Instance Attribute Summary collapse
-
#hosts ⇒ ActiveRecord::Relation<Mdm::Host>
readonly
Host that are tagged with this tag.
-
#hosts_tags ⇒ ActiveRecord::Relation<Mdm::HostTag>
Joins #hosts to this tag.
Instance Method Summary collapse
-
#destroy_if_orphaned ⇒ void
Destroy this tag if it has no #hosts_tags.
- #to_s ⇒ Object
Instance Attribute Details
#hosts ⇒ ActiveRecord::Relation<Mdm::Host> (readonly)
Host that are tagged with this tag.
29 |
# File 'app/models/mdm/tag.rb', line 29 has_many :hosts, :through => :hosts_tags, :class_name => 'Mdm::Host' |
#hosts_tags ⇒ ActiveRecord::Relation<Mdm::HostTag>
Joins #hosts to this tag.
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_orphaned ⇒ void
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 .empty? destroy end end end |
#to_s ⇒ Object
70 71 72 |
# File 'app/models/mdm/tag.rb', line 70 def to_s name end |