Last active
April 11, 2016 08:50
-
-
Save rusilko/ce4dbe061f479764c3f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Evaluate | |
def call(input_data, bank) | |
initial_data = input_data.merge(bank.parameters) | |
steps = bank.evaluation_steps | |
steps.inject(initial_data) do |data, (result_name, calculate_result)| | |
begin | |
data.merge({ result_name.to_sym => calculate_result.(data) }) | |
rescue ArgumentError | |
raise $!, "#{$!}, when using: #{calculate_result}, to calculate: #{result_name}", $!.backtrace | |
end | |
end | |
end | |
private | |
def merge_and_wrap(data, parameters) | |
DataWrapper.new(data.merge parameters) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment