lib/arql/ext/array.rb in arql-0.1.17 vs lib/arql/ext/array.rb in arql-0.1.18
- old
+ new
@@ -11,9 +11,25 @@
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)
+ puts Terminal::Table.new { |t|
+ t << attrs
+ t << :separator
+ each do |e|
+ t << e.attributes.values_at(*attrs.map(&:to_s))
+ end
+ }
+ else
+ puts Terminal::Table.new { |t|
+ v.each { |row| t << (row || :separator)}
+ }
+ end
+ end
+
def v
return self unless present?
t = []
if map(&:class).uniq.size == 1
if first.is_a?(ActiveRecord::Base)