Module: ArelExtensions::InsertManager
- Included in:
- Arel::InsertManager
- Defined in:
- lib/arel_extensions/insert_manager.rb
Defined Under Namespace
Classes: BulkValues
Instance Method Summary collapse
Instance Method Details
#bulk_insert(cols, data) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |