Skip to content

Commit

Permalink
Depreacate reimbursement hooks
Browse files Browse the repository at this point in the history
The introduction of dedicated events for succesful and failed reimbursement
made the existing hooks implemented as class attributes obsolete. They are
now deprecated, waiting for a major release before their complete removal.
  • Loading branch information
spaghetticode committed Mar 6, 2020
1 parent 7c202de commit 90bf905
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/app/models/spree/reimbursement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,20 @@ def perform!(created_by: nil)
if unpaid_amount_within_tolerance?
reimbursed!
Spree::Event.fire 'reimbursement_reimbursed', reimbursement: self
if reimbursement_success_hooks.any?
Spree::Deprecation.warn \
"reimbursement_success_hooks are deprecated. Please remove them " \
"and subscribe to `reimbursement_reimbursed` event instead", caller(1)
end
reimbursement_success_hooks.each { |hook| hook.call self }
else
errored!
Spree::Event.fire 'reimbursement_errored', reimbursement: self
if reimbursement_failure_hooks.any?
Spree::Deprecation.warn \
"reimbursement_failure_hooks are deprecated. Please remove them " \
"and subscribe to `reimbursement_errored` event instead", caller(1)
end
reimbursement_failure_hooks.each { |hook| hook.call self }
end

Expand Down

0 comments on commit 90bf905

Please sign in to comment.