File: isolate.rb

package info (click to toggle)
ruby-dependor 1.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 264 kB
  • sloc: ruby: 557; makefile: 2; sh: 1
file content (17 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module Dependor
  module Isolate
    def isolate(klass = nil, overrides = {}, &block)
      if block_given?
        klass = block.call
        caller_binding = block.binding
        injector = EvaluatingInjector.new(caller_binding)
      else
        sending_injector = SendingInjector.new(self)
        injector = CustomizedInjector.new(sending_injector, overrides)
      end
      dependecy_names = DependencyNamesCache.new
      instantiator = Instantiator.new(injector, dependecy_names)
      instantiator.instantiate(klass)
    end
  end
end