Class: PartialFinder::AssumptionGraph

Inherits:
Graph
  • Object
show all
Defined in:
lib/partial_finder/assumption_graph.rb

Overview

AssumptionGraph accepts a standard Graph class and augments it with more information about how each render chain terminates, ie what controller method is used and what route points to said controller method.

Given the flexiblity of metaprogramming and the many edge cases that exist even in a system with good conventions like the Rails rendering system, it’s best to consider the guesses that this class makes exactly that - guesses, and sometimes manual checking may be needed to ensure the correctness of it’s output.

See Graph and LinkSet for more information on the primitives that this class is based on.

Instance Attribute Summary collapse

Attributes inherited from Graph

#links, #structure

Instance Method Summary collapse

Methods inherited from Graph

from, #to_s

Constructor Details

#initialize(links, custom_rails_root = nil) ⇒ AssumptionGraph

Custom rails root needs to be set if the Rails root and current working directory of this class are not the same. This is needed to properly load and read controller code. Usually they will be the same, but during testing or when used outside of the standard rake context, may need to be set.



19
20
21
22
23
# File 'lib/partial_finder/assumption_graph.rb', line 19

def initialize(links, custom_rails_root = nil)
  super(links)
  @custom_rails_root = custom_rails_root
  @structure = structure.map{ |link| add_assumptions_to(link) }
end

Instance Attribute Details

#custom_rails_rootObject (readonly)

Returns the value of attribute custom_rails_root.



13
14
15
# File 'lib/partial_finder/assumption_graph.rb', line 13

def custom_rails_root
  @custom_rails_root
end