Class: MigrationPlans::ImportConfigService

Inherits:
Object
  • Object
show all
Defined in:
app/services/migration_plans/import_config_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_json, current_user) ⇒ ImportConfigService

Returns a new instance of ImportConfigService.



7
8
9
10
11
12
# File 'app/services/migration_plans/import_config_service.rb', line 7

def initialize(config_json, current_user)
  @config_json = config_json
  @current_user = current_user
  @errors = []
  @step_mapping = {} # Maps sequence to step objects for dependency resolution
end

Instance Attribute Details

#config_jsonObject (readonly)

Returns the value of attribute config_json.



5
6
7
# File 'app/services/migration_plans/import_config_service.rb', line 5

def config_json
  @config_json
end

#current_userObject (readonly)

Returns the value of attribute current_user.



5
6
7
# File 'app/services/migration_plans/import_config_service.rb', line 5

def current_user
  @current_user
end

#errorsObject (readonly)

Returns the value of attribute errors.



5
6
7
# File 'app/services/migration_plans/import_config_service.rb', line 5

def errors
  @errors
end

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/migration_plans/import_config_service.rb', line 14

def call
  config = parse_config
  return nil unless config

  validate_config(config)
  return nil if @errors.any?

  create_plan_with_steps(config)
rescue StandardError => e
  @errors << "Import failed: #{e.message}"
  nil
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/services/migration_plans/import_config_service.rb', line 27

def success?
  @errors.empty?
end