Skip to content

Commit

Permalink
Fix hydrator call context passing
Browse files Browse the repository at this point in the history
  • Loading branch information
pyromaniac committed Aug 7, 2024
1 parent 22dadaf commit ec5d084
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/operations/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def instantiate_form(operation_result)

def hydrate_params(form_class, params, **context)
hydrated_params = hydrators.inject({}) do |value, hydrator|
value.merge(hydrator.call(form_class, params, context).deep_symbolize_keys)
value.merge(hydrator.call(form_class, params, **context).deep_symbolize_keys)
end
hydrated_params.deep_merge!(params) if hydration_merge_params
hydrated_params
Expand Down
6 changes: 3 additions & 3 deletions spec/operations/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def build(**kwargs)
context "when on_failure callback failed" do
let(:on_failure_callback) { ->(_, **) { Dry::Monads::Failure(:wow) } }
let(:command_options) { { configuration: Operations.default_config.new(error_reporter: error_reporter) } }
let(:error_reporter) { proc {} }
let(:error_reporter) { -> {} }

before { allow(error_reporter).to receive(:call) }

Expand Down Expand Up @@ -463,7 +463,7 @@ def build(**kwargs)
context "when on_success callback failed but there is a wrapping transaction" do
let(:on_success) { [->(**) { Dry::Monads::Failure(:yay) }] }
let(:command_options) { { configuration: Operations.default_config.new(error_reporter: error_reporter) } }
let(:error_reporter) { proc {} }
let(:error_reporter) { -> {} }

before { allow(error_reporter).to receive(:call) }

Expand Down Expand Up @@ -494,7 +494,7 @@ def build(**kwargs)
context "when on_success callback failed" do
let(:on_success) { [->(**) { Dry::Monads::Failure(:yay) }] }
let(:command_options) { { configuration: Operations.default_config.new(error_reporter: error_reporter) } }
let(:error_reporter) { proc {} }
let(:error_reporter) { -> {} }

before { allow(error_reporter).to receive(:call) }

Expand Down
4 changes: 2 additions & 2 deletions spec/operations/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def call(_, **)
end
let(:default_options) do
{
model_map: proc { |_path| "DummyModel" },
hydrators: [proc { |_form_class, _params, **_context| { ignored: 42, name: "Batman" } }]
model_map: ->(_path) { "DummyModel" },
hydrators: [->(_form_class, _params, **_context) { { ignored: 42, name: "Batman" } }]
}
end
let(:options) { default_options }
Expand Down

0 comments on commit ec5d084

Please sign in to comment.