Class: Crosstest::Psychic::ScriptFactoryManager

Inherits:
FactoryManager show all
Defined in:
lib/crosstest/psychic/script_factory_manager.rb

Constant Summary

Constants inherited from FactoryManager

FactoryManager::BUILT_IN_DIR

Instance Attribute Summary

Attributes inherited from FactoryManager

#factories

Instance Method Summary collapse

Methods inherited from FactoryManager

#active?, #active_factories, autoload_factories!, clear, factory_classes, #initialize, register_factory

Constructor Details

This class inherits a constructor from Crosstest::Psychic::FactoryManager

Instance Method Details

#factories_for(script) ⇒ Object


4
5
6
7
8
9
10
11
12
# File 'lib/crosstest/psychic/script_factory_manager.rb', line 4

def factories_for(script)
  capable_factories = active_factories.select do | factory |
    factory.priority_for_script(script)
  end

  capable_factories.sort_by do |factory|
    factory.priority_for_script(script)
  end
end

#priority_for(script) ⇒ Object


14
15
16
17
18
# File 'lib/crosstest/psychic/script_factory_manager.rb', line 14

def priority_for(script)
  active_factories.map do | factory |
    factory.priority_for_script(script) || 0
  end.max
end