lib/arql/ext/array.rb in arql-0.1.10 vs lib/arql/ext/array.rb in arql-0.1.11

- old
+ new

@@ -10,6 +10,18 @@ raise 'All element should be an ActiveRecord instance object' unless all? { |e| e.is_a?(ActiveRecord::Base) } group_by(&:class).map do |(klass, records)| klass.to_upsert_sql(records, batch_size) end.join("\n") end + + def v + raise 'Empty array' unless present? + raise 'All elements must be instances of the same ActiveRecord model class' unless map(&:class).uniq.size == 1 && first.is_a?(ActiveRecord::Base) + t = [] + t << first.attribute_names + t << nil + each do |e| + t << e.attributes.values_at(*first.attribute_names) + end + t + end end