New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor calculators to be more opinionated what to compute #4041

Closed
wants to merge 15 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+2 −2
Diff settings

Always

Just for now

Viewing a subset of changes. View all

use the correct class name in the message. The caller is not returning

the subclassed calculator.
  • Loading branch information...
peterberkenbosch committed Dec 5, 2013
commit 2d5257e0fe89bab284003a36cb915350ec110e7d
@@ -9,11 +9,11 @@ def compute(computable)
# Spree::LineItem -> :compute_line_item
computable_name = computable.class.name.demodulize.underscore
method = "compute_#{computable_name}".to_sym
the_caller = caller[0].split(':')[0]
calculator_class = self.class
begin
self.send(method, computable)
rescue NoMethodError
raise NotImplementedError, "Please implement '#{method}(#{computable_name})' in your calculator: #{the_caller}"
raise NotImplementedError, "Please implement '#{method}(#{computable_name})' in your calculator: #{calculator_class.name}"
end
end
ProTip! Use n and p to navigate between commits in a pull request.