Parent

Class/Module Index [+]

Quicksearch

RR::Injections::MethodMissingInjection

Public Class Methods

create(subject) click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 5
def create(subject)
  instances[subject] ||= begin
    new(subject).bind
  end
end
exists?(subject) click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 11
def exists?(subject)
  instances.include?(subject)
end
new(subject) click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 16
def initialize(subject)
  @subject = subject
  @placeholder_method_defined = false
end

Public Instance Methods

bind() click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 21
def bind
  unless subject.respond_to?(original_method_alias_name)
    unless subject.respond_to?(:method_missing)
      @placeholder_method_defined = true
      subject_class.class_eval do
        def method_missing(method_name, *args, &block)
          super
        end
      end
    end
    subject_class.__send__(:alias_method, original_method_alias_name, :method_missing)
    bind_method
  end
  self
end
dispatch_method(method_name, args, block) click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 51
def dispatch_method(method_name, args, block)
  MethodDispatches::MethodMissingDispatch.new(subject, method_name, args, block).call
end
method_missing(method_name, *args, &block) click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 26
def method_missing(method_name, *args, &block)
  super
end
reset() click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 37
def reset
  if subject_has_method_defined?(original_method_alias_name)
    memoized_original_method_alias_name = original_method_alias_name
    placeholder_method_defined = @placeholder_method_defined
    subject_class.class_eval do
      remove_method :method_missing
      unless placeholder_method_defined
        alias_method :method_missing, memoized_original_method_alias_name
      end
      remove_method memoized_original_method_alias_name
    end
  end
end

Protected Instance Methods

bind_method() click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 60
def bind_method
  returns_method =         def method_missing(method_name, *args, &block)          RR::Injections::MethodMissingInjection.create(self).dispatch_method(method_name, args, block)        end
  subject_class.class_eval(returns_method, __FILE__, __LINE__ - 4)
end
original_method_alias_name() click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 69
def original_method_alias_name
  MethodDispatches::MethodMissingDispatch.original_method_missing_alias_name
end
subject_class() click to toggle source
# File lib/rr/injections/method_missing_injection.rb, line 56
def subject_class
  class << subject; self; end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.