Class: CallLogger::MethodWrapper
- Inherits:
-
Object
- Object
- CallLogger::MethodWrapper
- Defined in:
- lib/call_logger/call_logger.rb
Instance Attribute Summary collapse
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #call(method, args) ⇒ Object
-
#initialize(formatter:, logger:) ⇒ MethodWrapper
constructor
A new instance of MethodWrapper.
Constructor Details
#initialize(formatter:, logger:) ⇒ MethodWrapper
Returns a new instance of MethodWrapper.
5 6 7 8 |
# File 'lib/call_logger/call_logger.rb', line 5 def initialize(formatter:, logger: ) @formatter = formatter @logger = logger end |
Instance Attribute Details
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
3 4 5 |
# File 'lib/call_logger/call_logger.rb', line 3 def formatter @formatter end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
3 4 5 |
# File 'lib/call_logger/call_logger.rb', line 3 def logger @logger end |
Instance Method Details
#call(method, args) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/call_logger/call_logger.rb', line 10 def call(method, args) logger.call(formatter.before(method, args)) result = yield logger.call(formatter.after(method, result)) result rescue StandardError => e logger.call(formatter.error(method, e)) raise end |