Class: ToFactory::KlassInference
- Inherits:
-
Object
- Object
- ToFactory::KlassInference
- Defined in:
- lib/to_factory/klass_inference.rb
Instance Method Summary collapse
- #infer(factory_name, count = 0) ⇒ Object
-
#initialize(representations) ⇒ KlassInference
constructor
A new instance of KlassInference.
Constructor Details
#initialize(representations) ⇒ KlassInference
Returns a new instance of KlassInference.
9 10 11 12 13 14 15 |
# File 'lib/to_factory/klass_inference.rb', line 9 def initialize(representations) @mapping = {} representations.each do |r| set_mapping_from(r) end end |
Instance Method Details
#infer(factory_name, count = 0) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/to_factory/klass_inference.rb', line 17 def infer(factory_name, count=0) count = count + 1 result = @mapping[factory_name] return [result, count] if result.is_a? Class if result.nil? raise CannotInferClass.new(factory_name) end infer(result, count) end |