Class: ObjectTracer::MethodHijacker
- Inherits:
-
Object
- Object
- ObjectTracer::MethodHijacker
- Defined in:
- lib/object_tracer/method_hijacker.rb
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #hijack_methods! ⇒ Object
-
#initialize(target) ⇒ MethodHijacker
constructor
A new instance of MethodHijacker.
Constructor Details
#initialize(target) ⇒ MethodHijacker
Returns a new instance of MethodHijacker.
5 6 7 |
# File 'lib/object_tracer/method_hijacker.rb', line 5 def initialize(target) @target = target end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'lib/object_tracer/method_hijacker.rb', line 3 def target @target end |
Instance Method Details
#hijack_methods! ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/object_tracer/method_hijacker.rb', line 9 def hijack_methods! target.methods.each do |method_name| if is_writer_method?(method_name) redefine_writer_method!(method_name) elsif is_reader_method?(method_name) redefine_reader_method!(method_name) end end end |