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

### Home Classes Methods

### In Files

- lib/naught/null_class_builder/commands/pebble.rb

### Parent

Naught::NullClassBuilder::Command

### Methods

- ::new
- #call
- #parse_caller

### Class/Module Index

Quicksearch

- Naught
- Naught::Conversions
- Naught::NullClassBuilder
- Naught::NullClassBuilder::Command
- Naught::NullClassBuilder::Commands
- Naught::NullClassBuilder::Commands::DefineExplicitConversions
- Naught::NullClassBuilder::Commands::DefineImplicitConversions
- Naught::NullClassBuilder::Commands::Impersonate
- Naught::NullClassBuilder::Commands::Mimic
- Naught::NullClassBuilder::Commands::Pebble
- Naught::NullClassBuilder::Commands::PredicatesReturn
- Naught::NullClassBuilder::Commands::Singleton
- Naught::NullClassBuilder::Commands::Traceable
- Naught::NullObjectTag

No matching classes.

# Naught::NullClassBuilder::Commands::Pebble

### Public Class Methods

new(builder, output = $stdout) click to toggle source

    # File lib/naught/null_class_builder/commands/pebble.rb, line 7
    def initialize(builder, output = $stdout)
      @builder = builder
      @output = output
    end

### Public Instance Methods

call() click to toggle source

    # File lib/naught/null_class_builder/commands/pebble.rb, line 12
    def call
      defer do |subject|
        subject.module_exec(@output) do |output|

          define_method(:method_missing) do |method_name, *args, &block|
            pretty_args = args.collect(&:inspect).join(', ').gsub("\"", "'")
            output.puts "#{method_name}(#{pretty_args}) from #{parse_caller}"
            self
          end

          def parse_caller
            caller = Kernel.caller(2).first
            method_name = caller.match(/\`([\w\s]+(\(\d+\s\w+\))?[\w\s]*)/)
            method_name ? method_name[1] : caller
          end
          private :parse_caller
        end
      end
    end

parse_caller() click to toggle source

    # File lib/naught/null_class_builder/commands/pebble.rb, line 22
    def parse_caller
      caller = Kernel.caller(2).first
      method_name = caller.match(/\`([\w\s]+(\(\d+\s\w+\))?[\w\s]*)/)
      method_name ? method_name[1] : caller
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.