lib/blind_index/extensions.rb in blind_index-0.3.4 vs lib/blind_index/extensions.rb in blind_index-0.3.5

- old
+ new

@@ -5,11 +5,17 @@ def resolve_column_aliases(hash) new_hash = super if has_blind_indexes? hash.each do |key, _| if key.respond_to?(:to_sym) && (bi = klass.blind_indexes[key.to_sym]) && !new_hash[key].is_a?(ActiveRecord::StatementCache::Substitute) - new_hash[bi[:bidx_attribute]] = BlindIndex.generate_bidx(new_hash.delete(key), bi) + value = new_hash.delete(key) + new_hash[bi[:bidx_attribute]] = + if value.is_a?(Array) + value.map { |v| BlindIndex.generate_bidx(v, bi) } + else + BlindIndex.generate_bidx(value, bi) + end end end end new_hash end @@ -28,10 +34,16 @@ def resolve_column_aliases(klass, hash) new_hash = super if has_blind_indexes?(klass) hash.each do |key, _| if key.respond_to?(:to_sym) && (bi = klass.blind_indexes[key.to_sym]) && !new_hash[key].is_a?(ActiveRecord::StatementCache::Substitute) - new_hash[bi[:bidx_attribute]] = BlindIndex.generate_bidx(new_hash.delete(key), bi) + value = new_hash.delete(key) + new_hash[bi[:bidx_attribute]] = + if value.is_a?(Array) + value.map { |v| BlindIndex.generate_bidx(v, bi) } + else + BlindIndex.generate_bidx(value, bi) + end end end end new_hash end