Class: PrivatePlease::Tracking::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/private_please/tracking/result.rb

Instance Method Summary collapse

Constructor Details

#initialize(encountered_method_calls) ⇒ Result

Returns a new instance of Result.



6
7
8
9
# File 'lib/private_please/tracking/result.rb', line 6

def initialize(encountered_method_calls)
  @private_calls = encountered_method_calls.private_calls
  @public_calls = encountered_method_calls.public_calls
end

Instance Method Details

#public_methods_only_called_privatelyObject



11
12
13
# File 'lib/private_please/tracking/result.rb', line 11

def public_methods_only_called_privately
  @private_calls - @public_calls
end

#to_two_level_hashObject



15
16
17
18
19
20
21
22
# File 'lib/private_please/tracking/result.rb', line 15

def to_two_level_hash
  two_level_hash = Hash.new { |h, k| h[k] = {} }
  public_methods_only_called_privately.each do |class_plus_method|
    md = MethodDetails.from_class_plus_method(class_plus_method)
    two_level_hash[md.klass][md.separator_plus_method] = [md.source_path, md.lineno]
  end
  two_level_hash.delete_if { |_k, v| v.empty? }
end