active-hash / active_hash

A readonly ActiveRecord-esque base class that lets you use a hash, a Yaml file or a custom file as the datasource
MIT License
1.19k stars 178 forks source link

Fix #pluck method behavior when 3+ attributes specified #269

Closed h6ah4i closed 1 year ago

h6ah4i commented 1 year ago

Hi. I noticed that ActiveHash's #pluck method behaves differently from ActiveRecord one. This pull request fixes the issue.

Current behavior (ActiveHash v3.1.1)

Category.pluck(:id, :name, :language)
=> [
  [[1, "US"], "English"],
  [[2, "Canada"], "English"],
  [[3, "Mexico"], "Spanish"]
]

Expected behavior (same as ActiveRecord)

Category.pluck(:id, :name, :language)
=> [
  [1, "US", "English"],
  [2, "Canada", "English"],
  [3, "Mexico", "Spanish"]
]