Skip to content

Commit cb905b5

Browse files
Fix bug, where the block was not transferred when the instance was split
1 parent eb9d721 commit cb905b5

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

lib/resol/plugins.rb

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
module Resol
66
module Plugins
77
PLUGINS_PATH = Pathname("resol/plugins")
8+
89
class Manager
910
def self.resolve_module(module_name)
1011
Plugins.const_get(module_name)

lib/resol/service.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def plugin(...)
4747
manager.plugin(self, ...)
4848
end
4949

50-
def call(...)
51-
service = build(...)
50+
def call(*args, **kwargs, &)
51+
service = build(*args, **kwargs)
5252

5353
result = handle_catch(service) do
5454
service.instance_variable_set(:@__performing__, true)
5555
__run_callbacks__(service)
56-
service.call
56+
service.call(&)
5757
end
5858
return Resol::Success(result.data) if service.__result_method__called__
5959

spec/service_spec.rb

+13
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ def call
9999
end
100100
end
101101

102+
class YieldingService < SmartService
103+
def call
104+
success!(yield)
105+
end
106+
end
107+
102108
class PluginSuccessService < ReturnEngineService
103109
def call
104110
success!(:success_result)
@@ -243,6 +249,13 @@ def call
243249
expect { HackyService.call!(0) }.to raise_error(Resol::Service::InvalidCommandCall)
244250
end
245251
end
252+
253+
context "when block passed to the service" do
254+
it "yields block" do
255+
result = YieldingService.call! { "kek" }
256+
expect(result).to eq("kek")
257+
end
258+
end
246259
end
247260

248261
context "with Return on success plugin" do

0 commit comments

Comments
 (0)