Skip to content

Commit

Permalink
Merge pull request #4 from CrowdHailer/master
Browse files Browse the repository at this point in the history
Sends implementation to object methods rather than lambdas
  • Loading branch information
julianghionoiu committed Dec 10, 2015
2 parents 28b40a1 + c3e3e11 commit 6eba53a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions features/step_definitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,25 @@ def get_lambda(name)
end

When(/^I go live with the following implementations:$/) do |table|
method_map = table.raw.each_with_object({}) do |(method_name, implementation_name), out|
out[method_name] = IMPLEMENTATION_MAP.fetch(implementation_name)
implementation = table.raw.each_with_object(Object.new) do |(method_name, implementation_name), implementation|
implementation.define_singleton_method(method_name, &IMPLEMENTATION_MAP.fetch(implementation_name))
implementation
end

@captured_io = capture_subprocess_io do
@client.go_live_with(OpenStruct.new(method_map))
@client.go_live_with(implementation)
end

end

When(/^I do a trial run with the following implementations:$/) do |table|
method_map = table.raw.each_with_object({}) do |(method_name, implementation_name), out|
out[method_name] = IMPLEMENTATION_MAP.fetch(implementation_name)
implementation = table.raw.each_with_object(Object.new) do |(method_name, implementation_name), implementation|
implementation.define_singleton_method(method_name, &IMPLEMENTATION_MAP.fetch(implementation_name))
implementation
end

@captured_io = capture_subprocess_io do
@client.trial_run_with(OpenStruct.new(method_map))
@client.trial_run_with(implementation)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tdl/respond/obtain_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def respond_to(request)

# DEBT object is treated and a collection of anonymous methods and not a normal object this is not ideomatic ruby

result = @user_implementation.send(request.to_h[:method]).(*request.params)
result = @user_implementation.send(request.to_h[:method], *request.params)
rescue Exception => e
@logger.info "The user implementation has thrown exception. #{e.message}"
result = nil
Expand Down

0 comments on commit 6eba53a

Please sign in to comment.