Class: Metasploit::ERD::Cluster
- Inherits:
-
Object
- Object
- Metasploit::ERD::Cluster
- Defined in:
- lib/metasploit/erd/cluster.rb
Overview
A cluster of Class<ActiveRecord::Base>
that are connected by belongs_to
associations so that all foreign keys are
paired with their appropriate primary keys.
Instance Method Summary collapse
-
#class_set ⇒ Set<Class<ActiveRecord::Base>>
Clases that are reachable through
belongs_to
associations on classes passed asroots
to #initialize. -
#initialize(*roots) ⇒ Cluster
constructor
A new instance of Cluster.
Constructor Details
#initialize(*roots) ⇒ Cluster
Returns a new instance of Cluster.
9 10 11 |
# File 'lib/metasploit/erd/cluster.rb', line 9 def initialize(*roots) class_queue.concat(roots) end |
Instance Method Details
#class_set ⇒ Set<Class<ActiveRecord::Base>>
Clases that are reachable through belongs_to
associations on classes passed as roots
to #initialize.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/metasploit/erd/cluster.rb', line 16 def class_set until class_queue.empty? klass = class_queue.pop # add immediately to visited set in case there are recursive associations visited_class_set.add klass class_entity = Metasploit::ERD::Entity::Class.new(klass) class_entity.class_set.each do |set_class| unless visited_class_set.include? set_class class_queue << set_class end end superclass = klass.superclass unless superclass == ActiveRecord::Base || visited_class_set.include?(superclass) class_queue << superclass end end visited_class_set end |