Module: Cordon::Watchlist

Extended by:
MethodList
Defined in:
lib/cordon/watchlist.rb

Class Method Summary collapse

Methods included from MethodList

includes?, invoke_method, wrap_method, wrap_methods

Class Method Details

.incursion_reportObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cordon/watchlist.rb', line 17

def incursion_report
  report = <<-EOF.strip
=======================
Cordon Incursion Report
=======================
  EOF
  n = incursions.length
  max_width = n.to_s.length

  incursions_by_method = Hash.new { |hash, key| hash[key] = [] }
  incursions.each do |incursion|
    incursions_by_method[incursion.method_descriptor] << incursion
  end

  incursions_by_method.to_a.sort.each do |method_descriptor, incursions|
    report << "\n\n#{method_descriptor}\n#{'-' * method_descriptor.length}"
    incursions.each do |incursion|
      report << "\n" + incursion.backtrace.first.to_s
    end
  end
  report << "\n"
  report
end

.incursionsObject



13
14
15
# File 'lib/cordon/watchlist.rb', line 13

def incursions
  @incursions ||= []
end

.invoke_method(instance, subject, method, *args, &b) ⇒ Object



8
9
10
11
# File 'lib/cordon/watchlist.rb', line 8

def invoke_method(instance, subject, method, *args, &b)
  record_incursion(subject, method, args)
  super
end