Skip to content

Commit

Permalink
fix: pluck method of ActiveHash::Relation
Browse files Browse the repository at this point in the history
- execute method of symbol name specified by pluck for record
- Until v3.1.1, it was a specification to execute the method of the symbol name, so the same result is obtained.
  • Loading branch information
iberianpig committed Jan 31, 2024
1 parent cca9655 commit c447ce6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lib/active_hash/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,10 @@ def size
end

def pluck(*column_names)
symbolized_column_names = column_names.map(&:to_sym)

if symbolized_column_names.length == 1
column_name = symbolized_column_names.first
all.map { |record| record[column_name] }
if column_names.length == 1
all.map(&column_names.first.to_sym)
else
all.map do |record|
symbolized_column_names.map { |column_name| record[column_name] }
end
column_names.map { |column_name| all.map(&column_name.to_sym) }.then { |values| :zip.to_proc.(*values) }
end
end

Expand Down

0 comments on commit c447ce6

Please sign in to comment.