Method: PEROBS::ClassMap#keep

Defined in:
lib/perobs/ClassMap.rb

#keep(classes) ⇒ Object

Delete all classes unless they are contained in classes.

Parameters:

  • classes (Array of String)

    List of the class names



89
90
91
92
93
94
95
96
97
98
# File 'lib/perobs/ClassMap.rb', line 89

def keep(classes)
  @by_id.each.with_index do |klass, id|
    unless classes.include?(klass)
      # Delete the class from the @by_id list by setting the entry to nil.
      @by_id[id] = nil
      # Delete the corresponding @by_class entry as well.
      @by_class.delete(klass)
    end
  end
end