module GhostDog::ClassMethods

Protected Instance Methods

ghost_method(matcher = nil, options = {}, &block) click to toggle source
# File lib/ghost_dog.rb, line 57
def ghost_method(matcher = nil, options = {}, &block)
  _ghost_method_definitions << Responder.from(matcher, options, block)
end

Private Instance Methods

_ghost_method_definitions() click to toggle source
# File lib/ghost_dog.rb, line 63
def _ghost_method_definitions
  @_ghost_methods ||= [].tap do |defs|
    klasses_that_might_have_ghost_methods = []
    klasses_that_might_have_ghost_methods << superclass if defined?(superclass)
    klasses_that_might_have_ghost_methods.concat(included_modules)

    klasses_that_might_have_ghost_methods.select { |k| k.respond_to?(:_ghost_method_definitions, :include_private) }.each do |k|
      defs.concat(k.send(:_ghost_method_definitions).dup)
    end
  end
end