Class: CallLogger::MethodWrapper
- Inherits:
-
Object
- Object
- CallLogger::MethodWrapper
- Defined in:
- lib/call_logger/method_wrapper.rb
Instance Attribute Summary collapse
-
#extended_class ⇒ Object
readonly
Returns the value of attribute extended_class.
-
#owner_class ⇒ Object
readonly
Returns the value of attribute owner_class.
Instance Method Summary collapse
-
#initialize(extended_class, owner_class) ⇒ MethodWrapper
constructor
A new instance of MethodWrapper.
- #wrap_multiple(methods) ⇒ Object
- #wrap_single(method) ⇒ Object
Constructor Details
#initialize(extended_class, owner_class) ⇒ MethodWrapper
Returns a new instance of MethodWrapper.
5 6 7 8 |
# File 'lib/call_logger/method_wrapper.rb', line 5 def initialize(extended_class, owner_class) @extended_class = extended_class @owner_class = owner_class end |
Instance Attribute Details
#extended_class ⇒ Object (readonly)
Returns the value of attribute extended_class.
3 4 5 |
# File 'lib/call_logger/method_wrapper.rb', line 3 def extended_class @extended_class end |
#owner_class ⇒ Object (readonly)
Returns the value of attribute owner_class.
3 4 5 |
# File 'lib/call_logger/method_wrapper.rb', line 3 def owner_class @owner_class end |
Instance Method Details
#wrap_multiple(methods) ⇒ Object
21 22 23 |
# File 'lib/call_logger/method_wrapper.rb', line 21 def wrap_multiple(methods) extended_class.prepend(build_module(methods)) end |
#wrap_single(method) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/call_logger/method_wrapper.rb', line 10 def wrap_single(method) owner = @owner_class sep = separator extended_class.alias_method "#{method}_without_log", method extended_class.define_method method do |*args| owner.do_log("#{owner}#{sep}#{method}", args) do send("#{method}_without_log", *args) end end end |