Class: Flounder::Query::Insert

Inherits:
Base
  • Object
show all
Includes:
Returning
Defined in:
lib/flounder/query/insert.rb

Overview

An insert.

Instance Attribute Summary

Attributes inherited from Base

#bind_values, #domain, #engine, #entity, #manager

Instance Method Summary collapse

Methods included from Returning

#returning, #returning_fields, #to_sql

Methods inherited from Base

#column_name_to_entity, #kick, #measure, #parse_conditions, #to_sql, #where, #with

Methods included from Helpers::Entity

#convert_to_entity, #entity_like?

Constructor Details

#initialize(domain, into_entity) ⇒ Insert

Returns a new instance of Insert.



10
11
12
13
14
# File 'lib/flounder/query/insert.rb', line 10

def initialize domain, into_entity
  super domain, Arel::InsertManager, into_entity

  manager.into entity.table
end

Instance Method Details

#row(fields) ⇒ Object

Add one row to the inserts.



18
19
20
21
22
# File 'lib/flounder/query/insert.rb', line 18

def row fields
  manager.insert(
    fields.map { |k, v| 
      transform_tuple_for_set(k, v) })
end