Class: RSpec::Matchers::DifferentiateBlockMethodTypes Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/matchers/differentiate_block_method_types.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.

Evaluates a block in order to determine what methods, if any, it defines as instance methods (using def foo) vs singleton methods (using def self.foo).

Instance Method Summary (collapse)

Constructor Details

- (DifferentiateBlockMethodTypes) initialize(*block_args)

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.

A new instance of DifferentiateBlockMethodTypes

9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rspec/matchers/differentiate_block_method_types.rb', line 9
def initialize(*block_args, &block)
  @block_args = block_args
  @block = block
  ignore_macro_methods
  capture_added_methods(singletons_singleton_class, singleton_methods)
  capture_added_methods(singleton_class, instance_methods)
  singleton_class.class_exec(*block_args, &block)
end

Instance Method Details

- (Object) instance_methods

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.

25
26
27
# File 'lib/rspec/matchers/differentiate_block_method_types.rb', line 25
def instance_methods
  @instance_methods ||= []
end

- (Object) singleton_class

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.

40
41
42
# File 'lib/rspec/matchers/differentiate_block_method_types.rb', line 40
def singleton_class
  class << self; self; end
end

- (Object) singleton_methods

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.

21
22
23
# File 'lib/rspec/matchers/differentiate_block_method_types.rb', line 21
def singleton_methods
  @singleton_methods ||= []
end