Class: Naught::NullClassBuilder::Commands::Pebble Private

Inherits:
Naught::NullClassBuilder::Command show all
Defined in:
lib/naught/null_class_builder/commands/pebble.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.

Logs missing method calls and their call sites

Instance Attribute Summary

Attributes inherited from Naught::NullClassBuilder::Command

#builder

Instance Method Summary collapse

Constructor Details

#initialize(builder, output = $stdout) ⇒ Pebble

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.

Create a pebble command with optional output stream

Parameters:

  • builder (NullClassBuilder)
  • output (#puts) (defaults to: $stdout)

    output stream for log lines



15
16
17
18
# File 'lib/naught/null_class_builder/commands/pebble.rb', line 15

def initialize(builder, output = $stdout)
  super(builder)
  @output = output
end

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 logging method_missing hook



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/naught/null_class_builder/commands/pebble.rb', line 23

def call
  output = @output
  defer_prepend_module do
    define_method(:method_missing) do |method_name, *args|
      pretty_args = args.map(&:inspect).join(", ").tr('"', "'")
      caller_desc = Naught::CallerInfo.format_caller_for_pebble(Kernel.caller(1))
      output.puts "#{method_name}(#{pretty_args}) from #{caller_desc}"
      self
    end
  end
end