Consider using Module#prepend
over Module#class_eval
as it's much cleaner and least invasive method of overriding existing Spree
functionality.
Please, refer to the following articles for additional details about Module#prepend
and method lookup in Ruby:
- https://blog.newrelic.com/2016/12/15/ruby-agent-module-prepend-alias-method-chains/
- https://makandracards.com/makandra/23171-how-ruby-method-lookup-works
- https://stackoverflow.com/questions/4470108/when-monkey-patching-a-method-can-you-call-the-overridden-method-from-the-new-i
Usage example: