lib/metasploit/credential/entity_relationship_diagram.rb in metasploit-credential-3.0.4 vs lib/metasploit/credential/entity_relationship_diagram.rb in metasploit-credential-4.0.0
- old
+ new
@@ -34,32 +34,32 @@
#
# Class Methods
#
- # All {cluster clusters} of classes that are reachable through belongs_to from each ActiveRecord::Base descendant
+ # All {cluster clusters} of classes that are reachable through belongs_to from each ApplicationRecord descendant
#
- # @return [Hash{Class<ActiveRecord::Base> => Set<Class<ActiveRecord::Base>>}] Maps entry point to cluster to its
+ # @return [Hash{Class<ApplicationRecord> => Set<Class<ApplicationRecord>>}] Maps entry point to cluster to its
# cluster.
def self.cluster_by_class
cluster_by_class = {}
Metasploit::Credential::Engine.instance.eager_load!
- ActiveRecord::Base.descendants.each do |klass|
+ ApplicationRecord.descendants.each do |klass|
klass_cluster = cluster(klass)
cluster_by_class[klass] = klass_cluster
end
cluster_by_class
end
# Cluster of classes that are reachable through belongs_to from `classes`.
#
- # @param classes [Array<Class<ActiveRecord::Base>>] classes that must be in cluster. All other classes in the
+ # @param classes [Array<Class<ApplicationRecord>>] classes that must be in cluster. All other classes in the
# returned cluster will be classes to which `classes` belong directly or indirectly.
- # @return [Set<Class<ActiveRecord::Base>>]
+ # @return [Set<Class<ApplicationRecord>>]
def self.cluster(*classes)
class_queue = classes.dup
visited_class_set = Set.new
until class_queue.empty?
@@ -120,14 +120,14 @@
RailsERD::Domain.generate
end
# Set of largest clusters from {cluster_by_class}.
#
- # @return [Array<Set<Class<ActiveRecord::Base>>>]
+ # @return [Array<Set<Class<ApplicationRecord>>>]
def self.maximal_clusters
clusters = cluster_by_class.values
- unique_clusters = clusters.uniq
+ unique_clusters = clusters.distinct
maximal_clusters = unique_clusters.dup
cluster_queue = unique_clusters.dup
until cluster_queue.empty?
@@ -150,15 +150,15 @@
maximal_clusters
end
# Calculates the target classes for a polymorphic `belongs_to`.
#
- # @return [Array<ActiveRecord::Base>]
+ # @return [Array<ApplicationRecord>]
def self.polymorphic_classes(belongs_to_reflection)
name = belongs_to_reflection.name
- ActiveRecord::Base.descendants.each_with_object([]) { |descendant, target_classes|
+ ApplicationRecord.descendants.each_with_object([]) { |descendant, target_classes|
has_many_reflections = descendant.reflect_on_all_associations(:has_many)
has_many_reflections.each do |has_many_reflection|
as = has_many_reflection.options[:as]
@@ -166,6 +166,6 @@
target_classes << descendant
end
end
}
end
-end
\ No newline at end of file
+end