Class: Naught::NullClassBuilder::Commands::Callstack Private

Inherits:
Naught::NullClassBuilder::Command show all
Defined in:
lib/naught/null_class_builder/commands/callstack.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Records method calls made on null objects for debugging

When enabled, each null object instance tracks all method calls made to it, including the method name, arguments, and source location. Calls are grouped into "traces" - each time a method is called directly on the original null object (rather than on a chained result), a new trace begins.

This uses lightweight proxy objects for chaining so that we can distinguish between null.foo.bar (one trace with two calls) and null.foo; null.bar (two traces with one call each).

Examples:

Basic usage

NullObject = Naught.build do |config|
  config.callstack
end

null = NullObject.new
null.foo(1, 2).bar
null.baz

null.__call_trace__
# => [
#      [#<Naught::CallLocation foo(1, 2) at example.rb:8>,
#       #<Naught::CallLocation bar() at example.rb:8>],
#      [#<Naught::CallLocation baz() at example.rb:9>]
#    ]

Instance Attribute Summary

Attributes inherited from Naught::NullClassBuilder::Command

#builder

Instance Method Summary collapse

Methods inherited from Naught::NullClassBuilder::Command

#initialize

Constructor Details

This class inherits a constructor from Naught::NullClassBuilder::Command

Instance Method Details

#callvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Install the callstack tracking mechanism



40
41
42
43
44
# File 'lib/naught/null_class_builder/commands/callstack.rb', line 40

def call
  install_call_trace_accessor
  install_method_missing_tracking
  install_chain_proxy_class
end