Class: StorageService
- Inherits:
-
Object
- Object
- StorageService
- Defined in:
- lib/wingify/services/storage_service.rb
Instance Attribute Summary collapse
-
#storage_data ⇒ Object
Returns the value of attribute storage_data.
Instance Method Summary collapse
-
#get_data_from_storage(feature_key, context) ⇒ Hash
Retrieves data from storage based on the feature key and user ID.
-
#initialize ⇒ StorageService
constructor
A new instance of StorageService.
-
#set_data_in_storage(data, context) ⇒ Boolean
Stores data in the storage.
Constructor Details
#initialize ⇒ StorageService
Returns a new instance of StorageService.
26 27 28 |
# File 'lib/wingify/services/storage_service.rb', line 26 def initialize @storage_data = {} end |
Instance Attribute Details
#storage_data ⇒ Object
Returns the value of attribute storage_data.
24 25 26 |
# File 'lib/wingify/services/storage_service.rb', line 24 def storage_data @storage_data end |
Instance Method Details
#get_data_from_storage(feature_key, context) ⇒ Hash
Retrieves data from storage based on the feature key and user ID.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/wingify/services/storage_service.rb', line 34 def get_data_from_storage(feature_key, context) storage_instance = Storage.instance.get_connector # Check if the storage instance is available return StorageEnum::STORAGE_UNDEFINED if DataTypeUtil.is_null(storage_instance) || DataTypeUtil.is_undefined(storage_instance) begin data = storage_instance.get(feature_key, context.get_id) return data.nil? ? StorageEnum::NO_DATA_FOUND : data rescue StandardError => e LoggerService.log(LogLevelEnum::ERROR, "ERROR_READING_DATA_FROM_STORAGE", { err: e., an: ApiEnum::GET_FLAG, sId: context.get_session_id, uuid: context.get_uuid}) return StorageEnum::NO_DATA_FOUND end end |
#set_data_in_storage(data, context) ⇒ Boolean
Stores data in the storage.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/wingify/services/storage_service.rb', line 52 def set_data_in_storage(data, context) storage_instance = Storage.instance.get_connector # Check if the storage instance is available return false if storage_instance.nil? begin storage_instance.set(data) return true rescue StandardError => e LoggerService.log(LogLevelEnum::ERROR, "ERROR_STORING_DATA_IN_STORAGE", { err: e., an: ApiEnum::GET_FLAG, sId: context.get_session_id, uuid: context.get_uuid}) return false end end |