Class: Erbee::AssociationExplorer

Inherits:
Object
  • Object
show all
Defined in:
lib/erbee/association_explorer.rb

Instance Method Summary collapse

Constructor Details

#initialize(model_name, depth: Erbee.configuration.depth) ⇒ AssociationExplorer



6
7
8
9
10
11
12
13
# File 'lib/erbee/association_explorer.rb', line 6

def initialize(model_name, depth: Erbee.configuration.depth)
  @model_name = model_name
  @depth = depth
  @visited = {}
  @results = []
  # We use an existing PolymorphicCollector to gather reverse-polymorphic associations.
  @polymorphic_registry = PolymorphicCollector.collect!
end

Instance Method Details

#exploreObject



15
16
17
18
19
# File 'lib/erbee/association_explorer.rb', line 15

def explore
  start_model = model_class_for(@model_name)
  traverse(start_model, 0)
  @results
end