Sha256: af3dc95e2777bafbc97283d31060f4b440e3c5f0966c942ba34abcedfe3c34d9

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

module RR
  module MethodDispatches
    class MethodMissingDispatch < BaseMethodDispatch
      attr_reader :method_name
      def initialize(double_injection, method_name, args, block)
        @double_injection, @args, @block = double_injection, args, block
        @method_name = method_name
      end

      def call
        if double_injection.method_name == method_name
          space.record_call(subject, method_name, args, block)
          @double = find_double_to_attempt

          if double
            double.method_call(args)
            call_yields
            return_value = extract_subject_from_return_value(call_implementation)
            if after_call_proc
              extract_subject_from_return_value(after_call_proc.call(return_value))
            else
              return_value
            end
          else
            double_not_found_error
          end
        else
          call_original_method
        end
      end

      def call_original_method
        double_injection.bypass_bound_method do
          call_original_method_missing
        end
      end

      protected

      def original_method_missing_alias_name
        double_injection.original_method_missing_alias_name
      end

      def subject
        double_injection.subject
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
redinger-redinger-rr-0.10.3 lib/rr/method_dispatches/method_missing_dispatch.rb
redinger-rr-0.10.3 lib/rr/method_dispatches/method_missing_dispatch.rb