Module: Factree::Pathfinder Private

Defined in:
lib/factree/pathfinder.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Class Method Details

.find(raw_facts, &decide) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

See Also:



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/factree/pathfinder.rb', line 8

def self.find(raw_facts, &decide)
  facts_without_spy = Factree::Facts.coerce(raw_facts)
  required_facts = []
  facts = Factree::FactsSpy.new(facts_without_spy) do |*fact_names|
    required_facts += fact_names
  end

  conclusion = Factree::Facts.catch_missing_facts do
    conclusion = decide.call(facts)
    type_check_conclusion conclusion, &decide
    conclusion
  end

  Factree::Path.new(required_facts.uniq, conclusion)
end