Skip to content

Instantly share code, notes, and snippets.

@rusilko
Last active April 11, 2016 08:50
Show Gist options
  • Save rusilko/ce4dbe061f479764c3f1 to your computer and use it in GitHub Desktop.
Save rusilko/ce4dbe061f479764c3f1 to your computer and use it in GitHub Desktop.
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