Class: Data::New

Inherits:
Object
  • Object
show all
Defined in:
app/services/flexite/data/new.rb

Instance Method Summary collapse

Constructor Details

#initialize(migrator) ⇒ New

Returns a new instance of New.



3
4
5
6
7
# File 'app/services/flexite/data/new.rb', line 3

def initialize(migrator)
  @migrator = migrator
  @errors = Hash.new { |h, k| h[k] = [] }
  @result = {}
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/flexite/data/new.rb', line 9

def call
  @migrator.call.each do |root, configs|
    begin
      @result[root] = save_root(root, configs)
    rescue => exc
      @errors[root] << [exc.message, exc.backtrace]
    end
  end

  @result.tap do |result|
    result[:errors] = @errors
  end
end