Class: Fortifier::BatchUpdater

Inherits:
Object
  • Object
show all
Defined in:
app/models/fortifier/batch_updater.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(users_to_upd) ⇒ BatchUpdater

Returns a new instance of BatchUpdater.



7
8
9
10
11
12
# File 'app/models/fortifier/batch_updater.rb', line 7

def initialize(users_to_upd)
  @account_uuid = users_to_upd['account_uuid']
  @application_uuid = users_to_upd['application_uuid']
  @users_to_update = users_to_upd['users']
  @user_status = Hash.new { | h, k | h[k] = { status: :new, messages: [] }}
end

Instance Attribute Details

#account_uuidObject (readonly)

Returns the value of attribute account_uuid.



5
6
7
# File 'app/models/fortifier/batch_updater.rb', line 5

def 
  @account_uuid
end

#application_uuidObject (readonly)

Returns the value of attribute application_uuid.



5
6
7
# File 'app/models/fortifier/batch_updater.rb', line 5

def application_uuid
  @application_uuid
end

#user_statusObject (readonly)

Returns the value of attribute user_status.



5
6
7
# File 'app/models/fortifier/batch_updater.rb', line 5

def user_status
  @user_status
end

#users_to_updateObject (readonly)

Returns the value of attribute users_to_update.



5
6
7
# File 'app/models/fortifier/batch_updater.rb', line 5

def users_to_update
  @users_to_update
end

Instance Method Details

#perform_updatesObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/fortifier/batch_updater.rb', line 14

def perform_updates
  identify_deltas # Determine what we need to do
  users_with_unidentified_status = []
  
  user_status.each_pair do | , status_info |
    case status_info[:status]
    when :new
      add_new_user(, users_to_update[], status_info)
    when :delete
      unlink_user(, status_info)
    when :update
      update_user(, users_to_update[], status_info)
    when :error
      # Not doing anything with users that have an error
    else
      # Need to log and email users in this state
    end
  end
end