Skip to content

Commit

Permalink
Keep order array for #array_to_hash method
Browse files Browse the repository at this point in the history
  • Loading branch information
mico committed Jul 18, 2023
1 parent 7527140 commit c79934d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/pubid/core/identifier/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def array_to_hash(params)
params.inject({}) do |r, i|
result = r
i.each do |k, v|
result = result.merge(k => r.key?(k) ? [v, r[k]].flatten : v)
result = result.merge(k => r.key?(k) ? [r[k], v].flatten : v)
end
result
end
Expand Down
2 changes: 1 addition & 1 deletion spec/pubid_core/identifier/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
context "when same key repeating" do
let(:input) { [{ a: 1 }, { a: 2 }] }

it { is_expected.to eq({ a: [2, 1] }) }
it { is_expected.to eq({ a: [1, 2] }) }
end
end

Expand Down

0 comments on commit c79934d

Please sign in to comment.