Exception: Cordon::Violation
Constant Summary collapse
- SelfRegex =
/\/lib\/cordon.*\.rb\:\d+\:in/
- CustomFilterProcs =
[]
Instance Attribute Summary collapse
-
#method_descriptor ⇒ Object
Returns the value of attribute method_descriptor.
Class Method Summary collapse
- .add_custom_backtrace_filter(&proc) ⇒ Object
- .clear_custom_backtrace_filters ⇒ Object
- .from_invocation(subject, method, args) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#method_descriptor ⇒ Object
Returns the value of attribute method_descriptor.
20 21 22 |
# File 'lib/cordon/violation.rb', line 20 def method_descriptor @method_descriptor end |
Class Method Details
.add_custom_backtrace_filter(&proc) ⇒ Object
6 7 8 |
# File 'lib/cordon/violation.rb', line 6 def self.add_custom_backtrace_filter(&proc) CustomFilterProcs << proc end |
.clear_custom_backtrace_filters ⇒ Object
10 11 12 |
# File 'lib/cordon/violation.rb', line 10 def self.clear_custom_backtrace_filters CustomFilterProcs.clear end |
.from_invocation(subject, method, args) ⇒ Object
14 15 16 17 18 |
# File 'lib/cordon/violation.rb', line 14 def self.from_invocation(subject, method, args) method_descriptor = '%s#%s' % [subject, method] = '%s(%s)' % [method_descriptor, args.map(&:inspect).join(', ')] new().tap { |e| e.method_descriptor = method_descriptor } end |
Instance Method Details
#backtrace ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/cordon/violation.rb', line 22 def backtrace bt = super return if bt.nil? # Take anything in 'lib/cordon*.rb' off of the *top* of the backtrace so users don't get distracted by it bt.shift while bt.first =~ SelfRegex # Apply any other custom filters to the backtrace before returning it CustomFilterProcs.each do |filter| bt = filter.call(bt) end return bt end |