module GhostDog::InstanceMethods

Public Instance Methods

respond_to?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/ghost_dog.rb, line 12
def respond_to?(method, include_private = false)
  super || !!responding_ghost_method(method.to_s)
end

Private Instance Methods

_ghost_methods() click to toggle source
# File lib/ghost_dog.rb, line 18
def _ghost_methods
  _klass_where_ghost_method_definitions_are.send(:_ghost_method_definitions)
end
_klass_where_ghost_method_definitions_are() click to toggle source
# File lib/ghost_dog.rb, line 22
def _klass_where_ghost_method_definitions_are
  if self.class.is_a?(Class)
    singleton_class.extend(ClassMethods) unless singleton_class.is_a?(ClassMethods)

    singleton_class
  else
    self.class
  end
end
method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/ghost_dog.rb, line 45
def method_missing(method, *args, &block)
  if matcher = responding_ghost_method(method.to_s)
    matcher.call(self, _klass_where_ghost_method_definitions_are, method.to_s, args, block)
  else
    super
  end
end
responding_ghost_method(method) click to toggle source
# File lib/ghost_dog.rb, line 32
def responding_ghost_method(method)
  @_considered_methods ||= []
  return if @_considered_methods.include?(method)

  @_considered_methods << method

  _ghost_methods.detect do |matcher|
    matcher.matches?(self, method)
  end
ensure
  @_considered_methods = []
end