From 9bce773cd0d88ba7bf1dfc2fdf2b9c851070e176 Mon Sep 17 00:00:00 2001 From: Joshua Flack Date: Wed, 11 Sep 2024 16:40:37 -0400 Subject: [PATCH] update select method --- lib/active_force/active_query.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/active_force/active_query.rb b/lib/active_force/active_query.rb index cb54a7a..401da3a 100644 --- a/lib/active_force/active_query.rb +++ b/lib/active_force/active_query.rb @@ -78,9 +78,17 @@ def where args=nil, *rest super build_condition args, rest end - def select *selected_fields - selected_fields.map! { |field| mappings[field] } - super *selected_fields + def select *selected_fields, &block + if block + result = [] + self.each do |record| + result << record if block.call(record) + end + result + else + selected_fields.map! { |field| mappings[field] } + super *selected_fields + end end def ids