lib/arql/ext/array.rb in arql-0.2.2 vs lib/arql/ext/array.rb in arql-0.2.3

- old
+ new

@@ -11,11 +11,19 @@ group_by(&:class).map do |(klass, records)| klass.to_upsert_sql(records, batch_size) end.join("\n") end - def t(*attrs) - if attrs.present? && present? && first.is_a?(ActiveRecord::Base) + def t(*attrs, **options) + if (attrs.present? || options.present? && options[:except]) && present? && first.is_a?(ActiveRecord::Base) + if options.present? && options[:except] + attrs = first.attribute_names.map(&:to_sym) if attrs.empty? + if options[:except].is_a?(Regexp) + attrs.reject! { |e| e =~ options[:except] } + else + attrs -= [options[:except]].flatten + end + end puts Terminal::Table.new { |t| t << attrs t << :separator each do |e| t << e.attributes.values_at(*attrs.map(&:to_s))