Class: ThreeScale::Backend::ProviderKeyChangeUseCase
- Inherits:
-
Object
- Object
- ThreeScale::Backend::ProviderKeyChangeUseCase
- Defined in:
- lib/3scale/backend/use_cases/provider_key_change_use_case.rb
Instance Method Summary collapse
-
#initialize(old_key, new_key) ⇒ ProviderKeyChangeUseCase
constructor
A new instance of ProviderKeyChangeUseCase.
- #process ⇒ Object
Constructor Details
#initialize(old_key, new_key) ⇒ ProviderKeyChangeUseCase
Returns a new instance of ProviderKeyChangeUseCase.
5 6 7 8 9 10 |
# File 'lib/3scale/backend/use_cases/provider_key_change_use_case.rb', line 5 def initialize(old_key, new_key) @old_key = old_key @new_key = new_key validate_input end |
Instance Method Details
#process ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/3scale/backend/use_cases/provider_key_change_use_case.rb', line 12 def process default_service_id = Service.default_id(@old_key) # Change the provider key on all the services and # add all the services to the new provider service_ids.each do |service_id| storage.set Service.storage_key(service_id, :provider_key), @new_key storage.sadd Service.storage_key_by_provider(@new_key, :ids), service_id end # Set the default service id to the new provider storage.set Service.storage_key_by_provider(@new_key, :id), default_service_id # Remove the old provider key and services associated to it storage.del Service.storage_key_by_provider(@old_key, :id) storage.del Service.storage_key_by_provider(@old_key, :ids) clear_cache service_ids end |