Sha256: 7e745c60ae4ab756fa8c2ece437d717b74d008a495e697ccd6a2c7bde18be146
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module Ahnnotate module Facet module Models class ResolveActiveRecordModels def to_proc method(:call).to_proc end def call(object_space) tree = {} object_space.each do |_class_name, extracted_class| superclass = extracted_class.superclass tree[superclass] ||= Set.new tree[superclass].add(extracted_class) end activerecord_family = gather_family(object_space["::ActiveRecord::Base"], tree) activerecord_family.each do |individual| individual.is_a_kind_of_activerecord_base = true end object_space.values - [object_space[""], object_space["::ActiveRecord::Base"]] end private def gather_family(node, tree) gather_family_helper(node, tree).flatten end def gather_family_helper(node, tree) if tree[node].nil? return node end [node] + tree[node].map { |child| gather_family_helper(child, tree) } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ahnnotate-0.5.1 | lib/ahnnotate/facet/models/resolve_active_record_models.rb |
ahnnotate-0.5.0 | lib/ahnnotate/facet/models/resolve_active_record_models.rb |