Skip to content

Commit

Permalink
Use method for getting proper tag class
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Dec 12, 2017
1 parent 5549221 commit 9da6220
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/mixins/assignment_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def assignments
end
end

def tag_class(klass)
klass == "VmOrTemplate" ? "vm" : klass.underscore
end

# @param target
# @option options :parents
# @option options :tag_list
Expand All @@ -196,8 +200,7 @@ def get_assigned_for_target(target, options = {})
tlist = Tagging.where("tags.name like '/managed/%'")
.where(:taggable => parents)
.references(:tag).includes(:tag).map do |t|
klass = t.taggable_type
lower_klass = klass == "VmOrTemplate" ? "vm" : klass.underscore
lower_klass = tag_class(t.taggable_type)
"#{lower_klass}/tag#{t.tag.name}"
end
tagged_resources = tlist.flat_map { |t| assignments_cached[t] }.uniq
Expand Down

0 comments on commit 9da6220

Please sign in to comment.