Class: Fortifier::BatchUpdater
- Inherits:
-
Object
- Object
- Fortifier::BatchUpdater
- Defined in:
- app/models/fortifier/batch_updater.rb
Instance Attribute Summary collapse
-
#account_uuid ⇒ Object
readonly
Returns the value of attribute account_uuid.
-
#application_uuid ⇒ Object
readonly
Returns the value of attribute application_uuid.
-
#user_status ⇒ Object
readonly
Returns the value of attribute user_status.
-
#users_to_update ⇒ Object
readonly
Returns the value of attribute users_to_update.
Instance Method Summary collapse
-
#initialize(users_to_upd) ⇒ BatchUpdater
constructor
A new instance of BatchUpdater.
- #perform_updates ⇒ Object
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_uuid ⇒ Object (readonly)
Returns the value of attribute account_uuid.
5 6 7 |
# File 'app/models/fortifier/batch_updater.rb', line 5 def account_uuid @account_uuid end |
#application_uuid ⇒ Object (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_status ⇒ Object (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_update ⇒ Object (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_updates ⇒ Object
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 | login, status_info | case status_info[:status] when :new add_new_user(login, users_to_update[login], status_info) when :delete unlink_user(login, status_info) when :update update_user(login, users_to_update[login], 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 |