Class: Naught::NullClassBuilder::Commands::Traceable Private

Inherits:
Naught::NullClassBuilder::Command show all
Defined in:
lib/naught/null_class_builder/commands/traceable.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 the source location where a null object was created

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 traceable initializer



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/naught/null_class_builder/commands/traceable.rb', line 13

def call
  defer_prepend_module do
    attr_reader :__file__, :__line__

    define_method(:initialize) do |options = {}|
      backtrace = options.fetch(:caller) { Kernel.caller(3) }
      caller_data = Naught::CallerInfo.parse(backtrace[0])
      @__file__ = caller_data[:path]
      @__line__ = caller_data[:lineno]
      super(options)
    end
  end
end