Class: Mdm::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Mdm::Tag
- 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.
27 |
# File 'app/models/mdm/tag.rb', line 27 has_many :hosts, :through => :hosts_tags, :class_name => 'Mdm::Host' |
#hosts_tags ⇒ ActiveRecord::Relation<Mdm::HostTag>
Joins #hosts to this tag.
10 11 12 13 |
# File 'app/models/mdm/tag.rb', line 10 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
52 53 54 55 56 57 58 |
# File 'app/models/mdm/tag.rb', line 52 def destroy_if_orphaned self.class.transaction do if .empty? destroy end end end |
#to_s ⇒ Object
60 61 62 |
# File 'app/models/mdm/tag.rb', line 60 def to_s name end |