Class: Dynamoid::Persistence::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamoid/persistence/import.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model_class, array_of_attributes) ⇒ Import

Returns a new instance of Import.



13
14
15
16
# File 'lib/dynamoid/persistence/import.rb', line 13

def initialize(model_class, array_of_attributes)
  @model_class = model_class
  @array_of_attributes = array_of_attributes
end

Class Method Details

.call(model_class, array_of_attributes) ⇒ Object



9
10
11
# File 'lib/dynamoid/persistence/import.rb', line 9

def self.call(model_class, array_of_attributes)
  new(model_class, array_of_attributes).call
end

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dynamoid/persistence/import.rb', line 18

def call
  models = @array_of_attributes.map(&method(:build_model))

  unless Dynamoid.config.backoff
    import(models)
  else
    import_with_backoff(models)
  end

  models.each do |m|
    m.new_record = false
    m.clear_changes_information
  end
  models
end