Class: Arel::Insert
- Defined in:
- lib/arel/algebra/relations/writes.rb,
lib/arel/engines/sql/relations/writes.rb,
lib/arel/engines/memory/relations/writes.rb
Instance Attribute Summary
Attributes inherited from Compound
Attributes included from Relation
Instance Method Summary collapse
- #call ⇒ Object
- #eval ⇒ Object
-
#initialize(relation, record) ⇒ Insert
constructor
A new instance of Insert.
- #to_sql(include_returning = true) ⇒ Object
Methods inherited from Compound
#attributes, #build_query, #engine, #eql?, #hash, requires, #unoperated_rows
Methods included from Relation
#bind, #christener, #compiler, #exclusion_predicate_sql, #externalizable?, #externalize, #inclusion_predicate_sql, #join?, #primary_key, #session
Methods included from Relation::DefaultOperations
#attributes, #groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken, #wheres
Methods included from Relation::AttributeAccessable
#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of
Methods included from Relation::Operable
#alias, #join, #lock, #outer_join
Methods included from Relation::Operable::Writable
Methods included from Relation::Enumerable
Constructor Details
#initialize(relation, record) ⇒ Insert
Returns a new instance of Insert.
15 16 17 |
# File 'lib/arel/algebra/relations/writes.rb', line 15 def initialize(relation, record) @relation, @record = relation, record.bind(relation) end |
Instance Method Details
#call ⇒ Object
19 20 21 |
# File 'lib/arel/algebra/relations/writes.rb', line 19 def call engine.create(self) end |
#eval ⇒ Object
3 4 5 |
# File 'lib/arel/engines/memory/relations/writes.rb', line 3 def eval unoperated_rows + [Row.new(self, record.values.collect(&:value))] end |
#to_sql(include_returning = true) ⇒ Object
9 10 11 |
# File 'lib/arel/engines/sql/relations/writes.rb', line 9 def to_sql(include_returning = true) compiler.insert_sql(include_returning) end |