Class: Dbwatcher::Storage::BaseStorage Abstract
- Inherits:
-
Object
- Object
- Dbwatcher::Storage::BaseStorage
- Includes:
- Concerns::ErrorHandler, Concerns::Timestampable
- Defined in:
- lib/dbwatcher/storage/base_storage.rb
Overview
Subclass and implement specific storage logic
Base class for all storage implementations
Provides common functionality for storage classes including file management, error handling, validation, and timestamping. Follows the Ruby style guide patterns for class organization.
Direct Known Subclasses
QueryStorage, SessionStorage, SystemInfoStorage, TableStorage
Constant Summary collapse
- DEFAULT_PERMISSIONS =
Configuration constants
0o755
- JSON_FILE_EXTENSION =
".json"
Instance Attribute Summary collapse
-
#file_manager ⇒ FileManager
readonly
The file manager instance.
-
#storage_path ⇒ String
readonly
The configured storage path.
Instance Method Summary collapse
-
#initialize(storage_path = nil) ⇒ BaseStorage
constructor
Initializes the base storage with configured path and file manager.
Methods included from Concerns::Timestampable
#age, included, #initialize_timestamps, #recently_created?, #recently_updated?, #touch_updated_at
Methods included from Concerns::ErrorHandler
#safe_operation, #with_error_handling
Constructor Details
#initialize(storage_path = nil) ⇒ BaseStorage
Initializes the base storage with configured path and file manager
Sets up the storage path from configuration, creates a file manager instance, and initializes timestamps.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dbwatcher/storage/base_storage.rb', line 51 def initialize(storage_path = nil) @storage_path = storage_path || Dbwatcher.configuration.storage_path # Ensure storage path is valid if @storage_path.nil? || @storage_path.to_s.strip.empty? raise StorageError, "Storage path cannot be nil or empty. Please configure a valid storage path." end @file_manager = FileManager.new(@storage_path) ensure_storage_directory end |
Instance Attribute Details
#file_manager ⇒ FileManager (readonly)
Returns the file manager instance.
42 43 44 |
# File 'lib/dbwatcher/storage/base_storage.rb', line 42 def file_manager @file_manager end |
#storage_path ⇒ String (readonly)
Returns the configured storage path.
39 40 41 |
# File 'lib/dbwatcher/storage/base_storage.rb', line 39 def storage_path @storage_path end |