Class Index [+]

Quicksearch

RR::Injections::SingletonMethodAddedInjection

Public Class Methods

create(subject) click to toggle source
   # File lib/rr/injections/singleton_method_added_injection.rb, line 5
5:         def create(subject)
6:           instances[subject] ||= begin
7:             new(subject).bind
8:           end
9:         end
exists?(subject) click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 11
11:         def exists?(subject)
12:           instances.include?(subject)
13:         end
new(subject) click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 16
16:       def initialize(subject)
17:         @subject = subject
18:         @placeholder_method_defined = false
19:       end

Public Instance Methods

bind() click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 21
21:       def bind
22:         unless subject.respond_to?(original_method_alias_name)
23:           unless subject.respond_to?(:singleton_method_added)
24:             @placeholder_method_defined = true
25:             subject_class.class_eval do
26:               def singleton_method_added(method_name)
27:                 super
28:               end
29:             end
30:           end
31: 
32:           memoized_subject = subject
33:           memoized_original_method_alias_name = original_method_alias_name
34:           subject_class.__send__(:alias_method, original_method_alias_name, :singleton_method_added)
35:           subject_class.__send__(:define_method, :singleton_method_added) do |method_name_arg|
36:             if Injections::DoubleInjection.exists?(memoized_subject, method_name_arg)
37:               Injections::DoubleInjection.create(memoized_subject, method_name_arg).send(:deferred_bind_method)
38:             end
39:             send(memoized_original_method_alias_name, method_name_arg)
40:           end
41:         end
42:         self
43:       end
reset() click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 45
45:       def reset
46:         if subject_has_method_defined?(original_method_alias_name)
47:           memoized_original_method_alias_name = original_method_alias_name
48:           placeholder_method_defined = @placeholder_method_defined
49:           subject_class.class_eval do
50:             remove_method :singleton_method_added
51:             unless placeholder_method_defined
52:               alias_method :singleton_method_added, memoized_original_method_alias_name
53:             end
54:             remove_method memoized_original_method_alias_name
55:           end
56:         end
57:       end
singleton_method_added(method_name) click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 26
26:               def singleton_method_added(method_name)
27:                 super
28:               end

Protected Instance Methods

original_method_alias_name() click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 64
64:       def original_method_alias_name
65:         "__rr__original_singleton_method_added"
66:       end
subject_class() click to toggle source
    # File lib/rr/injections/singleton_method_added_injection.rb, line 60
60:       def subject_class
61:         class << subject; self; end
62:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.