lib/arql/ext/array.rb in arql-0.2.4 vs lib/arql/ext/array.rb in arql-0.2.5
- old
+ new
@@ -13,11 +13,13 @@
end.join("\n")
end
def t(*attrs, **options)
if (attrs.present? || options.present? && options[:except]) && present? && first.is_a?(ActiveRecord::Base)
+ column_names = first.attribute_names.map(&:to_sym)
+ attrs = attrs.flat_map { |e| e.is_a?(Regexp) ? column_names.grep(e) : e }.uniq
if options.present? && options[:except]
- attrs = first.attribute_names.map(&:to_sym) if attrs.empty?
+ attrs = column_names if attrs.empty?
if options[:except].is_a?(Regexp)
attrs.reject! { |e| e =~ options[:except] }
else
attrs -= [options[:except]].flatten
end