Class: Flexite::Data::NewService

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

Instance Method Summary collapse

Constructor Details

#initialize(migrator) ⇒ NewService

Returns a new instance of NewService.



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

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

Instance Method Details

#callObject



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

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