Module: Logging::ThirdPartyTransaction::MethodWrapper
- Included in:
- ApiProviderFactory, BGS::FlashUpdater, CentralMail::SubmitForm4142Job, EVSS::DisabilityCompensationForm::SubmitForm0781, EVSS::DisabilityCompensationForm::SubmitForm526, EVSS::DisabilityCompensationForm::SubmitForm8940, EVSS::DisabilityCompensationForm::UploadBddInstructions, EVSS::DocumentUpload, Form526Submission, Lighthouse::PollForm526Pdf, Sidekiq::Form526BackupSubmissionProcess::Processor, V0::IntentToFilesController, V0::UploadSupportingEvidencesController
- Defined in:
- lib/logging/third_party_transaction.rb
Instance Method Summary collapse
Instance Method Details
#wrap_with_logging(*method_names, additional_class_logs: {}, additional_instance_logs: {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/logging/third_party_transaction.rb', line 20 def wrap_with_logging(*method_names, additional_class_logs: {}, additional_instance_logs: {}) # including the instance method helpers inside this method makes them # available on the instance with access to the current scope, (e.g. # current_user at the controller level) include(ScopedInstanceMethods) proxy = Module.new do method_names.each do |method_name| # define patchable method(s) with the same name inside of a proxy module. define_method(method_name) do |*args, &block| log_3pi_begin(method_name, additional_class_logs, additional_instance_logs) # delegate to the original behavior result = super(*args, &block) log_3pi_complete(method_name, additional_class_logs, additional_instance_logs) result end end end # prepend the proxy module, allowing both our wrapped version to run # logging as well as delegating to the original. prepend(proxy) end |