module ArelExtensions::InsertManager
Public Instance Methods
bulk_insert(cols, data)
click to toggle source
# File lib/arel_extensions/insert_manager.rb, line 5 def bulk_insert(cols, data) raise ArgumentError, 'cols must be present' if cols.blank? columns = case cols.first when Array case cols.first.first when Arel::Attributes::Attribute cols when String, Symbol cols.map {|c| [@ast.relation[c.first]] } else raise ArgumentError, "cols has an invalid type: #{cols.first.first.class}" end when String, Symbol cols.map { |c| @ast.relation[c] } else raise ArgumentError, "cols has an invalid type: #{cols.first.class}" end self.values = BulkValues.new(columns, data) @ast.columns = columns end