Class: EnMasse::Inserts
- Inherits:
-
Object
- Object
- EnMasse::Inserts
- Defined in:
- lib/en_masse/inserts.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(collection) ⇒ Inserts
constructor
A new instance of Inserts.
Constructor Details
#initialize(collection) ⇒ Inserts
Returns a new instance of Inserts.
6 7 8 9 |
# File 'lib/en_masse/inserts.rb', line 6 def initialize collection @collection = collection @collection += collect_new_dependents end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
4 5 6 |
# File 'lib/en_masse/inserts.rb', line 4 def collection @collection end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/en_masse/inserts.rb', line 11 def call ActiveRecord::Base.connection.transaction do by_model.each do |model, records| model.insert_collection(records) end end end |