Class: Uses::CircularDependency::Analyzer
- Inherits:
-
Object
- Object
- Uses::CircularDependency::Analyzer
- Defined in:
- lib/uses/circular_dependency/analyzer.rb
Instance Method Summary collapse
- #analyze! ⇒ Object
- #circular_dependency? ⇒ Boolean
-
#initialize(uses_method_args) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #notify! ⇒ Object
Constructor Details
#initialize(uses_method_args) ⇒ Analyzer
Returns a new instance of Analyzer.
8 9 10 |
# File 'lib/uses/circular_dependency/analyzer.rb', line 8 def initialize(uses_method_args) @uses_method_args = uses_method_args end |
Instance Method Details
#analyze! ⇒ Object
12 13 14 |
# File 'lib/uses/circular_dependency/analyzer.rb', line 12 def analyze! @dependency, @path_to_dependency = transitive_dependency?(@uses_method_args.klass_with_uses,@uses_method_args.klass_being_used) end |
#circular_dependency? ⇒ Boolean
16 17 18 |
# File 'lib/uses/circular_dependency/analyzer.rb', line 16 def circular_dependency? !!@dependency end |
#notify! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/uses/circular_dependency/analyzer.rb', line 20 def notify! raise "You have not called analyze!" if @dependency.nil? notifier = case @uses_method_args.uses_config.on_circular_dependency when :warn then Uses::CircularDependency::LogNotifer.new(@uses_method_args, @path_to_dependency) when :ignore then Uses::CircularDependency::IgnoreNotifier.new(@uses_method_args, @path_to_dependency) when :raise_error then Uses::CircularDependency::RaiseErrorNotifier.new(@uses_method_args, @path_to_dependency) end notifier.notify! end |