Sha256: 140e19181d70ff534e45585caf6b7214345a0696738e4e06ecb4b0b220941458
Contents?: true
Size: 1016 Bytes
Versions: 1
Compression:
Stored size: 1016 Bytes
Contents
module Omnitest class Psychic class FactoryManager include Omnitest::Core::Logger BUILT_IN_DIR = File.expand_path('../factories', __FILE__) class << self def autoload_factories! # Load built-in task factories Dir.glob("#{BUILT_IN_DIR}/*.rb", File::FNM_CASEFOLD).each do |task_factory_file| require task_factory_file end end def factory_classes @factory_classes ||= Set.new end def register_factory(klass) factory_classes.add klass end def clear factory_classes.clear end end attr_reader :factories def initialize(*args) @factories = self.class.factory_classes.map { |k| k.new(*args) } end def active_factories factories.select(&:active?).sort_by(&:priority) end def active?(klass) factories.find do | factory | factory.is_a? klass end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omnitest-psychic-0.0.9 | lib/omnitest/psychic/factory_manager.rb |