module Missingly::Matchers

Private Class Methods

included(klass) click to toggle source
# File lib/missingly/matchers.rb, line 161
def self.included(klass)
  klass.extend ClassMethods
end

Public Instance Methods

method_missing(method_name, *args, &block) click to toggle source
Calls superclass method
# File lib/missingly/matchers.rb, line 139
def method_missing(method_name, *args, &block)
  self.class.missingly_matchers.values.each do |matcher|
    next unless matcher.should_respond_to?(self, method_name)
    next if matcher.options[:class_method]

    Missingly::Mutex.synchronize do
      self.class.missingly_methods_for_matcher(matcher.matchable) << method_name

      matcher.define(self, method_name)

      self.class.missingly_subclasses.each do |subclass|
        subclass.undef_parent_missingly_methods matcher.matchable
      end

      return public_send(method_name, *args, &block)
    end
  end
  super
end

Private Instance Methods

respond_to_missing?(method_name, include_all) click to toggle source
Calls superclass method
# File lib/missingly/matchers.rb, line 131
def respond_to_missing?(method_name, include_all)
  self.class.missingly_matchers.values.each do |matcher|
    return true if matcher.should_respond_to?(self, method_name.to_sym) && !(matcher.options[:class_method])
  end
  super
end