File: injection.rb

package info (click to toggle)
ruby-rr 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,424 kB
  • sloc: ruby: 11,405; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 879 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module RR
  module Injections
    class Injection
      extend(Module.new do
        def instances
          @instances ||= HashWithObjectIdKey.new
        end
      end)

      include Space::Reader
      include ClassInstanceMethodDefined

      def subject_has_method_defined?(method_name_in_question)
        class_instance_method_defined(subject_class, method_name_in_question)
      end

      def subject_has_original_method?
        subject_has_method_defined?(original_method_alias_name)
      end

      def original_method
        subject_class.instance_method(original_method_alias_name)
      end

    protected
      def subject_respond_to_method?(subject, method_name)
        subject_has_method_defined?(method_name) ||
          class_instance_method_defined(subject_class, :respond_to?) &&
          subject.respond_to?(method_name)
      end
    end
  end
end