Class: InfinumAzure::Users::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/infinum_azure/users/migration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Migration

Returns a new instance of Migration.



14
15
16
17
18
# File 'lib/tasks/infinum_azure/users/migration.rb', line 14

def initialize(response)
  @response = response
  @users_updated_count = 0
  @emails_not_found = []
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



12
13
14
# File 'lib/tasks/infinum_azure/users/migration.rb', line 12

def response
  @response
end

Class Method Details

.perform(response = {}) ⇒ Object



8
9
10
# File 'lib/tasks/infinum_azure/users/migration.rb', line 8

def self.perform(response = {})
  new(response).perform
end

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tasks/infinum_azure/users/migration.rb', line 20

def perform
  user_migration_scope.call.each do |record|
    resource = response.find { |object| object['email'] == record.email }
    emails_not_found.push(record.email) && next if resource.nil?

    user_migration_operation.call(record, resource)
    self.users_updated_count += 1
  end

  self
end

#resultsObject



32
33
34
35
36
37
38
39
# File 'lib/tasks/infinum_azure/users/migration.rb', line 32

def results
  <<~HEREDOC
    Count of updated resources: #{users_updated_count}
    Emails not found on Infinum Azure AD B2C: #{emails_not_found.size}
    Emails:
    #{emails_not_found.join("\n")}
  HEREDOC
end